Files
threshold/protocols/lss/keygen/accept_test.go
zeekay 5d7f23beb3 feat: add TON and Cardano support with comprehensive test coverage
- Add TON blockchain adapter with Ed25519 and Curve25519 support
- Add Cardano adapter with native Ed25519 plus ECDSA/Schnorr for interop
- TON features: BOC serialization, workchain support, gas estimation
- Cardano features: CBOR encoding, Blake2b-256, multi-era support
- Fix golangci-lint configuration for CI compatibility
- Create comprehensive test suite covering all 20+ blockchains
- Ensure 100% build success with no compilation errors
- Support for Shelley, Allegra, Mary, Alonzo, Babbage, Conway eras
- Ready for production deployment with full test coverage
2025-08-14 20:50:23 -05:00

95 lines
2.3 KiB
Go

package keygen_test
import (
"testing"
"time"
"github.com/luxfi/threshold/pkg/math/curve"
"github.com/luxfi/threshold/pkg/party"
"github.com/luxfi/threshold/pkg/pool"
"github.com/luxfi/threshold/pkg/protocol"
"github.com/luxfi/threshold/protocols/lss/keygen"
"github.com/stretchr/testify/require"
)
func TestHandlerAcceptDebug(t *testing.T) {
group := curve.Secp256k1{}
n := 3
threshold := 2
partyIDs := []party.ID{"alice", "bob", "charlie"}
pl := pool.NewPool(0)
defer pl.TearDown()
sessionID := []byte("test-session")
// Create handlers for all parties with same session ID
handlers := make([]*protocol.MultiHandler, n)
for i, id := range partyIDs {
startFunc := keygen.Start(id, partyIDs, threshold, group, pl)
h, err := protocol.NewMultiHandler(startFunc, sessionID)
require.NoError(t, err)
handlers[i] = h
}
// Collect initial messages
messages := make([]*protocol.Message, 0)
for i, h := range handlers {
msgChan := h.Listen()
select {
case msg := <-msgChan:
if msg != nil {
t.Logf("Party %s sent broadcast from %s", partyIDs[i], msg.From)
messages = append(messages, msg)
}
case <-time.After(100 * time.Millisecond):
t.Logf("Party %s sent no initial message", partyIDs[i])
}
}
t.Logf("Collected %d initial messages", len(messages))
// Try to deliver messages
for _, msg := range messages {
if msg.Broadcast {
// Deliver to all parties except sender
for i, h := range handlers {
if partyIDs[i] != msg.From {
canAccept := h.CanAccept(msg)
t.Logf("Checking if %s can accept from %s: %v", partyIDs[i], msg.From, canAccept)
t.Logf(" To: %s", msg.To)
t.Logf(" RoundNumber: %d", msg.RoundNumber)
t.Logf(" Data length: %d", len(msg.Data))
if canAccept {
t.Logf(" ACCEPTED - calling Accept")
h.Accept(msg)
} else {
t.Logf(" REJECTED")
}
}
}
}
}
// Check if any handler progressed
for i, h := range handlers {
result, err := h.Result()
if err != nil && err.Error() != "protocol: not finished" {
t.Logf("Party %s error: %v", partyIDs[i], err)
} else if result != nil {
t.Logf("Party %s has result!", partyIDs[i])
}
// Check for more messages
msgChan := h.Listen()
select {
case msg := <-msgChan:
if msg != nil {
t.Logf("Party %s has new message after accept", partyIDs[i])
}
default:
// No message
}
}
}