From 1caa2a05ee7257a1da20c02e17415b4fe9868c21 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 15:26:14 -0700 Subject: [PATCH 1/8] add new state, use mod to check state if closed prematurely, unit test --- sdk/state/ingest.go | 2 +- sdk/state/ingest_test.go | 107 +++++++++++++++++++++++++++++++++++++++ sdk/state/state.go | 8 ++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/sdk/state/ingest.go b/sdk/state/ingest.go index 056fb5b3..7ce9ff1e 100644 --- a/sdk/state/ingest.go +++ b/sdk/state/ingest.go @@ -32,7 +32,7 @@ func (c *Channel) IngestTx(txOrderID int64, txXDR, resultXDR, resultMetaXDR stri if err != nil { return fmt.Errorf("getting channel state: %w", err) } - if cs == StateClosed { + if cs == StateClosed || cs == StateClosedWithOutdatedState { return fmt.Errorf("channel has been closed") } diff --git a/sdk/state/ingest_test.go b/sdk/state/ingest_test.go index 8708c519..3a8a0518 100644 --- a/sdk/state/ingest_test.go +++ b/sdk/state/ingest_test.go @@ -1322,3 +1322,110 @@ func TestChannel_IngestTx_OpenClose(t *testing.T) { err = initiatorChannel.IngestTx(4, "", "", "") require.EqualError(t, err, "channel has been closed") } + +func TestChannel_IngestTx_ingestOldTransactions(t *testing.T) { + initiatorSigner := keypair.MustRandom() + responderSigner := keypair.MustRandom() + initiatorEscrow := keypair.MustRandom().FromAddress() + responderEscrow := keypair.MustRandom().FromAddress() + + // Given a channel with observation periods set to 1. + initiatorChannel := NewChannel(Config{ + NetworkPassphrase: network.TestNetworkPassphrase, + Initiator: true, + LocalSigner: initiatorSigner, + RemoteSigner: responderSigner.FromAddress(), + LocalEscrowAccount: initiatorEscrow, + RemoteEscrowAccount: responderEscrow, + MaxOpenExpiry: 2 * time.Hour, + }) + responderChannel := NewChannel(Config{ + NetworkPassphrase: network.TestNetworkPassphrase, + Initiator: false, + LocalSigner: responderSigner, + RemoteSigner: initiatorSigner.FromAddress(), + LocalEscrowAccount: responderEscrow, + RemoteEscrowAccount: initiatorEscrow, + MaxOpenExpiry: 2 * time.Hour, + }) + + // Put channel into the Open state. + { + m, err := initiatorChannel.ProposeOpen(OpenParams{ + Asset: NativeAsset, + ExpiresAt: time.Now().Add(5 * time.Minute), + StartingSequence: 101, + ObservationPeriodTime: 10, + ObservationPeriodLedgerGap: 10, + }) + require.NoError(t, err) + m, err = responderChannel.ConfirmOpen(m.Envelope) + require.NoError(t, err) + _, err = initiatorChannel.ConfirmOpen(m.Envelope) + require.NoError(t, err) + + ftx, err := initiatorChannel.OpenTx() + require.NoError(t, err) + + ftxXDR, err := ftx.Base64() + require.NoError(t, err) + + successResultXDR, err := txbuildtest.BuildResultXDR(true) + require.NoError(t, err) + resultMetaXDR, err := txbuildtest.BuildFormationResultMetaXDR(txbuildtest.FormationResultMetaParams{ + InitiatorSigner: initiatorSigner.Address(), + ResponderSigner: responderSigner.Address(), + InitiatorEscrow: initiatorEscrow.Address(), + ResponderEscrow: responderEscrow.Address(), + StartSequence: 101, + Asset: txnbuild.NativeAsset{}, + }) + require.NoError(t, err) + + err = initiatorChannel.IngestTx(2, ftxXDR, successResultXDR, resultMetaXDR) + require.NoError(t, err) + err = responderChannel.IngestTx(2, ftxXDR, successResultXDR, resultMetaXDR) + require.NoError(t, err) + } + initiatorChannel.UpdateLocalEscrowAccountBalance(100) + responderChannel.UpdateRemoteEscrowAccountBalance(100) + + placeholderXDR := "AAAAAgAAAAIAAAADABArWwAAAAAAAAAAWPnYf+6kQN3t44vgesQdWh4JOOPj7aer852I7RJhtzAAAAAWg8TZOwANrPwAAAAKAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABABArWwAAAAAAAAAAWPnYf+6kQN3t44vgesQdWh4JOOPj7aer852I7RJhtzAAAAAWg8TZOwANrPwAAAALAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAABAAAAAMAD/39AAAAAAAAAAD49aUpVx7fhJPK6wDdlPJgkA1HkAi85qUL1tii8YSZzQAAABdjSVwcAA/8sgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAECtbAAAAAAAAAAD49aUpVx7fhJPK6wDdlPJgkA1HkAi85qUL1tii8YSZzQAAABee5CYcAA/8sgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAMAECtbAAAAAAAAAABY+dh/7qRA3e3ji+B6xB1aHgk44+Ptp6vznYjtEmG3MAAAABaDxNk7AA2s/AAAAAsAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAECtbAAAAAAAAAABY+dh/7qRA3e3ji+B6xB1aHgk44+Ptp6vznYjtEmG3MAAAABZIKg87AA2s/AAAAAsAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=" + validResultXDR, err := txbuildtest.BuildResultXDR(true) + + oldDeclTx, oldCloseTx, err := responderChannel.CloseTxs() + require.NoError(t, err) + oldDeclXDR, err := oldDeclTx.Base64() + require.NoError(t, err) + oldCloseXDR, err := oldCloseTx.Base64() + require.NoError(t, err) + + // New payment. + { + close, err := initiatorChannel.ProposePayment(8) + require.NoError(t, err) + close, err = responderChannel.ConfirmPayment(close.Envelope) + require.NoError(t, err) + _, err = initiatorChannel.ConfirmPayment(close.Envelope) + require.NoError(t, err) + } + + // Close channel with old transactions. + { + err = initiatorChannel.IngestTx(1, oldDeclXDR, validResultXDR, placeholderXDR) + require.NoError(t, err) + cs, err := initiatorChannel.State() + require.NoError(t, err) + assert.Equal(t, StateClosingWithOutdatedState, cs) + + err = initiatorChannel.IngestTx(1, oldCloseXDR, validResultXDR, placeholderXDR) + require.NoError(t, err) + cs, err = initiatorChannel.State() + require.NoError(t, err) + assert.Equal(t, StateClosedWithOutdatedState, cs) + } + + // Once closed with old closeTx, ingesting new transactions should error. + err = initiatorChannel.IngestTx(1, oldCloseXDR, validResultXDR, placeholderXDR) + require.EqualError(t, err, "channel has been closed") +} diff --git a/sdk/state/state.go b/sdk/state/state.go index 06a9f243..8cc7aad7 100644 --- a/sdk/state/state.go +++ b/sdk/state/state.go @@ -135,6 +135,7 @@ const ( StateNone StateOpen StateClosingWithOutdatedState + StateClosedWithOutdatedState StateClosing StateClosed ) @@ -161,11 +162,14 @@ func (c *Channel) State() (State, error) { latestCloseSequence := txs.Close.SequenceNumber() initiatorEscrowSeqNum := c.initiatorEscrowAccount().SequenceNumber + s := c.openAgreement.Envelope.Details.StartingSequence - if initiatorEscrowSeqNum == c.openAgreement.Envelope.Details.StartingSequence { + if initiatorEscrowSeqNum == s { return StateOpen, nil - } else if initiatorEscrowSeqNum < latestDeclSequence { + } else if initiatorEscrowSeqNum < latestDeclSequence && initiatorEscrowSeqNum%2 == s%2 { return StateClosingWithOutdatedState, nil + } else if initiatorEscrowSeqNum < latestDeclSequence && initiatorEscrowSeqNum%2 != s%2 { + return StateClosedWithOutdatedState, nil } else if initiatorEscrowSeqNum == latestDeclSequence { return StateClosing, nil } else if initiatorEscrowSeqNum >= latestCloseSequence { From b87e7c6d9b5a258eab2934b1c1668dcb5c0013e4 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 15:30:38 -0700 Subject: [PATCH 2/8] lint --- sdk/state/ingest_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/state/ingest_test.go b/sdk/state/ingest_test.go index 3a8a0518..f24c38f8 100644 --- a/sdk/state/ingest_test.go +++ b/sdk/state/ingest_test.go @@ -1392,6 +1392,7 @@ func TestChannel_IngestTx_ingestOldTransactions(t *testing.T) { placeholderXDR := "AAAAAgAAAAIAAAADABArWwAAAAAAAAAAWPnYf+6kQN3t44vgesQdWh4JOOPj7aer852I7RJhtzAAAAAWg8TZOwANrPwAAAAKAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABABArWwAAAAAAAAAAWPnYf+6kQN3t44vgesQdWh4JOOPj7aer852I7RJhtzAAAAAWg8TZOwANrPwAAAALAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAABAAAAAMAD/39AAAAAAAAAAD49aUpVx7fhJPK6wDdlPJgkA1HkAi85qUL1tii8YSZzQAAABdjSVwcAA/8sgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAECtbAAAAAAAAAAD49aUpVx7fhJPK6wDdlPJgkA1HkAi85qUL1tii8YSZzQAAABee5CYcAA/8sgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAMAECtbAAAAAAAAAABY+dh/7qRA3e3ji+B6xB1aHgk44+Ptp6vznYjtEmG3MAAAABaDxNk7AA2s/AAAAAsAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAECtbAAAAAAAAAABY+dh/7qRA3e3ji+B6xB1aHgk44+Ptp6vznYjtEmG3MAAAABZIKg87AA2s/AAAAAsAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=" validResultXDR, err := txbuildtest.BuildResultXDR(true) + require.NoError(t, err) oldDeclTx, oldCloseTx, err := responderChannel.CloseTxs() require.NoError(t, err) From cbcd5416e68d803cbf08ab73d76c4e8b5fcd5d49 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:10:24 -0700 Subject: [PATCH 3/8] move seq mod check to txbuild package --- sdk/state/state.go | 7 +++++-- sdk/txbuild/sequence.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sdk/state/state.go b/sdk/state/state.go index 8cc7aad7..d7c748de 100644 --- a/sdk/state/state.go +++ b/sdk/state/state.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + "github.com/stellar/experimental-payment-channels/sdk/txbuild" "github.com/stellar/go/keypair" "github.com/stellar/go/network" "github.com/stellar/go/txnbuild" @@ -166,9 +167,11 @@ func (c *Channel) State() (State, error) { if initiatorEscrowSeqNum == s { return StateOpen, nil - } else if initiatorEscrowSeqNum < latestDeclSequence && initiatorEscrowSeqNum%2 == s%2 { + } else if initiatorEscrowSeqNum < latestDeclSequence && + txbuild.SequenceNumberToTransactionType(s, initiatorEscrowSeqNum) == txbuild.TransactionTypeDeclaration { return StateClosingWithOutdatedState, nil - } else if initiatorEscrowSeqNum < latestDeclSequence && initiatorEscrowSeqNum%2 != s%2 { + } else if initiatorEscrowSeqNum < latestDeclSequence && + txbuild.SequenceNumberToTransactionType(s, initiatorEscrowSeqNum) == txbuild.TransactionTypeClose { return StateClosedWithOutdatedState, nil } else if initiatorEscrowSeqNum == latestDeclSequence { return StateClosing, nil diff --git a/sdk/txbuild/sequence.go b/sdk/txbuild/sequence.go index c34ea9ba..0e36655b 100644 --- a/sdk/txbuild/sequence.go +++ b/sdk/txbuild/sequence.go @@ -5,3 +5,17 @@ const m = 2 func startSequenceOfIteration(startSequence int64, iterationNumber int64) int64 { return startSequence + iterationNumber*m } + +type TransactionType string + +const ( + TransactionTypeDeclaration TransactionType = "declaration" + TransactionTypeClose TransactionType = "close" +) + +func SequenceNumberToTransactionType(startingSeqNum, seqNum int64) TransactionType { + if startingSeqNum%m == seqNum%m { + return TransactionTypeDeclaration + } + return TransactionTypeClose +} From c1426f119d29d722dc892b2e157685af61b5937d Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:24:11 -0700 Subject: [PATCH 4/8] add test --- sdk/txbuild/sequence_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sdk/txbuild/sequence_test.go diff --git a/sdk/txbuild/sequence_test.go b/sdk/txbuild/sequence_test.go new file mode 100644 index 00000000..8ac97412 --- /dev/null +++ b/sdk/txbuild/sequence_test.go @@ -0,0 +1,21 @@ +package txbuild + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_sequence(t *testing.T) { + assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(100, 100)) + assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(100, 101)) + + assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 101)) + assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 102)) + + assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 103)) + assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 104)) + + assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(100, 102)) + assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(100, 103)) +} From d5e1329d027b68d5ba9745db8ebd74415bf77f2a Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:28:08 -0700 Subject: [PATCH 5/8] add a transaction type for all possible seq num values --- sdk/txbuild/sequence.go | 8 +++++++- sdk/txbuild/sequence_test.go | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk/txbuild/sequence.go b/sdk/txbuild/sequence.go index 0e36655b..ecb0b580 100644 --- a/sdk/txbuild/sequence.go +++ b/sdk/txbuild/sequence.go @@ -9,12 +9,18 @@ func startSequenceOfIteration(startSequence int64, iterationNumber int64) int64 type TransactionType string const ( + TransactionTypeNone TransactionType = "none" + TransactionTypeFormation TransactionType = "formation" TransactionTypeDeclaration TransactionType = "declaration" TransactionTypeClose TransactionType = "close" ) func SequenceNumberToTransactionType(startingSeqNum, seqNum int64) TransactionType { - if startingSeqNum%m == seqNum%m { + if startingSeqNum == seqNum { + return TransactionTypeFormation + } else if startingSeqNum+1 == seqNum { + return TransactionTypeNone + } else if startingSeqNum%m == seqNum%m { return TransactionTypeDeclaration } return TransactionTypeClose diff --git a/sdk/txbuild/sequence_test.go b/sdk/txbuild/sequence_test.go index 8ac97412..26fb435d 100644 --- a/sdk/txbuild/sequence_test.go +++ b/sdk/txbuild/sequence_test.go @@ -7,11 +7,11 @@ import ( ) func Test_sequence(t *testing.T) { - assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(100, 100)) - assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(100, 101)) + assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(100, 100)) + assert.Equal(t, TransactionTypeNone, SequenceNumberToTransactionType(100, 101)) - assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 101)) - assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 102)) + assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(101, 101)) + assert.Equal(t, TransactionTypeNone, SequenceNumberToTransactionType(101, 102)) assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 103)) assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 104)) From 0b1d1df7aaa8b51a4eef16e4d891caf4c5612fd8 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:32:16 -0700 Subject: [PATCH 6/8] add panic --- sdk/txbuild/sequence.go | 3 +-- sdk/txbuild/sequence_test.go | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/txbuild/sequence.go b/sdk/txbuild/sequence.go index ecb0b580..425fa1b0 100644 --- a/sdk/txbuild/sequence.go +++ b/sdk/txbuild/sequence.go @@ -9,7 +9,6 @@ func startSequenceOfIteration(startSequence int64, iterationNumber int64) int64 type TransactionType string const ( - TransactionTypeNone TransactionType = "none" TransactionTypeFormation TransactionType = "formation" TransactionTypeDeclaration TransactionType = "declaration" TransactionTypeClose TransactionType = "close" @@ -19,7 +18,7 @@ func SequenceNumberToTransactionType(startingSeqNum, seqNum int64) TransactionTy if startingSeqNum == seqNum { return TransactionTypeFormation } else if startingSeqNum+1 == seqNum { - return TransactionTypeNone + panic("invalid sequence number") } else if startingSeqNum%m == seqNum%m { return TransactionTypeDeclaration } diff --git a/sdk/txbuild/sequence_test.go b/sdk/txbuild/sequence_test.go index 26fb435d..5cc0e251 100644 --- a/sdk/txbuild/sequence_test.go +++ b/sdk/txbuild/sequence_test.go @@ -8,10 +8,7 @@ import ( func Test_sequence(t *testing.T) { assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(100, 100)) - assert.Equal(t, TransactionTypeNone, SequenceNumberToTransactionType(100, 101)) - assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(101, 101)) - assert.Equal(t, TransactionTypeNone, SequenceNumberToTransactionType(101, 102)) assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 103)) assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 104)) From 84a3348c2823663d17471dba3e74176a89c09cc2 Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:34:00 -0700 Subject: [PATCH 7/8] name change --- sdk/txbuild/sequence_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/txbuild/sequence_test.go b/sdk/txbuild/sequence_test.go index 5cc0e251..3dda3f3e 100644 --- a/sdk/txbuild/sequence_test.go +++ b/sdk/txbuild/sequence_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" ) -func Test_sequence(t *testing.T) { +func TestSequenceNumberToTransactionType(t *testing.T) { assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(100, 100)) assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(101, 101)) From f3ad59fa4aff41821d3a4cae0d7bcc5ffd84543a Mon Sep 17 00:00:00 2001 From: Alec Charbonneau Date: Mon, 13 Sep 2021 16:54:25 -0700 Subject: [PATCH 8/8] make easier to read --- sdk/txbuild/sequence.go | 22 ++++++++++++++-------- sdk/txbuild/sequence_test.go | 3 +++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sdk/txbuild/sequence.go b/sdk/txbuild/sequence.go index 425fa1b0..19d918c5 100644 --- a/sdk/txbuild/sequence.go +++ b/sdk/txbuild/sequence.go @@ -1,5 +1,7 @@ package txbuild +import "fmt" + const m = 2 func startSequenceOfIteration(startSequence int64, iterationNumber int64) int64 { @@ -9,18 +11,22 @@ func startSequenceOfIteration(startSequence int64, iterationNumber int64) int64 type TransactionType string const ( - TransactionTypeFormation TransactionType = "formation" - TransactionTypeDeclaration TransactionType = "declaration" - TransactionTypeClose TransactionType = "close" + TransactionTypeUnrecognized TransactionType = "unrecognized" + TransactionTypeFormation TransactionType = "formation" + TransactionTypeDeclaration TransactionType = "declaration" + TransactionTypeClose TransactionType = "close" ) func SequenceNumberToTransactionType(startingSeqNum, seqNum int64) TransactionType { - if startingSeqNum == seqNum { + seqRelative := seqNum - startingSeqNum + if seqRelative == 0 { return TransactionTypeFormation - } else if startingSeqNum+1 == seqNum { - panic("invalid sequence number") - } else if startingSeqNum%m == seqNum%m { + } else if seqRelative > 0 && seqRelative < m { + return TransactionTypeUnrecognized + } else if seqRelative%m == 0 { return TransactionTypeDeclaration + } else if seqRelative%m == 1 { + return TransactionTypeClose } - return TransactionTypeClose + panic(fmt.Errorf("unhandled sequence number: startingSeqNum=%d seqNum=%d", startingSeqNum, seqNum)) } diff --git a/sdk/txbuild/sequence_test.go b/sdk/txbuild/sequence_test.go index 3dda3f3e..8f9eef9c 100644 --- a/sdk/txbuild/sequence_test.go +++ b/sdk/txbuild/sequence_test.go @@ -10,6 +10,9 @@ func TestSequenceNumberToTransactionType(t *testing.T) { assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(100, 100)) assert.Equal(t, TransactionTypeFormation, SequenceNumberToTransactionType(101, 101)) + assert.Equal(t, TransactionTypeUnrecognized, SequenceNumberToTransactionType(100, 101)) + assert.Equal(t, TransactionTypeUnrecognized, SequenceNumberToTransactionType(101, 102)) + assert.Equal(t, TransactionTypeDeclaration, SequenceNumberToTransactionType(101, 103)) assert.Equal(t, TransactionTypeClose, SequenceNumberToTransactionType(101, 104))