github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/flow/transaction_test.go (about) 1 package flow_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 "github.com/onflow/flow-go/model/flow" 10 "github.com/onflow/flow-go/utils/unittest" 11 ) 12 13 func TestTransaction_SignatureOrdering(t *testing.T) { 14 tx := flow.NewTransactionBody() 15 16 proposerAddress := unittest.RandomAddressFixture() 17 proposerKeyIndex := uint64(1) 18 proposerSequenceNumber := uint64(42) 19 proposerSignature := []byte{1, 2, 3} 20 21 authorizerAddress := unittest.RandomAddressFixture() 22 authorizerKeyIndex := uint64(0) 23 authorizerSignature := []byte{4, 5, 6} 24 25 payerAddress := unittest.RandomAddressFixture() 26 payerKeyIndex := uint64(0) 27 payerSignature := []byte{7, 8, 9} 28 29 tx.SetProposalKey(proposerAddress, proposerKeyIndex, proposerSequenceNumber) 30 tx.AddPayloadSignature(proposerAddress, proposerKeyIndex, proposerSignature) 31 32 tx.SetPayer(payerAddress) 33 tx.AddEnvelopeSignature(payerAddress, payerKeyIndex, payerSignature) 34 35 tx.AddAuthorizer(authorizerAddress) 36 tx.AddPayloadSignature(authorizerAddress, authorizerKeyIndex, authorizerSignature) 37 38 require.Len(t, tx.PayloadSignatures, 2) 39 40 signatureA := tx.PayloadSignatures[0] 41 signatureB := tx.PayloadSignatures[1] 42 43 assert.Equal(t, proposerAddress, signatureA.Address) 44 assert.Equal(t, authorizerAddress, signatureB.Address) 45 } 46 47 func TestTransaction_Status(t *testing.T) { 48 statuses := map[flow.TransactionStatus]string{ 49 flow.TransactionStatusUnknown: "UNKNOWN", 50 flow.TransactionStatusPending: "PENDING", 51 flow.TransactionStatusFinalized: "FINALIZED", 52 flow.TransactionStatusExecuted: "EXECUTED", 53 flow.TransactionStatusSealed: "SEALED", 54 flow.TransactionStatusExpired: "EXPIRED", 55 } 56 57 for status, value := range statuses { 58 assert.Equal(t, status.String(), value) 59 } 60 }