Skip to content

Commit

Permalink
[test] refs #279 - Add generic TestEncodeSkycoinTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
e1Ru1o committed Jan 26, 2020
1 parent f6a1552 commit 49f3717
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/coin/skycoin/models/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1870,3 +1870,50 @@ func Test_newCreatedTransactionOutputs(t *testing.T) {
outputs = outputs[:len(outputs)-1]
}
}

func TestEncodeSkycoinTransaction(t *testing.T) {
type SkycoinReadableTxn interface {
skytypes.SkycoinTxn
skytypes.ReadableTxn
}

date, err := time.Parse(time.RFC3339, "2012-11-01T22:08:41+00:00")
require.NoError(t, err)

tests := []struct {
name string
txn SkycoinReadableTxn
}{
{
name: "SkycoinPendingTransaction",
txn: &SkycoinPendingTransaction{
Transaction: &readable.UnconfirmedTransactionVerbose{
Transaction: readable.BlockTransactionVerbose{
InnerHash: "0000000000000000000000000000000000000000000000000000000000000000",
Hash: "78877fa898f0b4c45c9c33ae941e40617ad7c8657a307db62bc5691f92f4f60e",
},
Announced: date,
},
},
},
{
name: "SkycoinCreatedTransaction",
txn: &SkycoinCreatedTransaction{
skyTxn: api.CreatedTransaction{
InnerHash: "0000000000000000000000000000000000000000000000000000000000000000",
TxID: "78877fa898f0b4c45c9c33ae941e40617ad7c8657a307db62bc5691f92f4f60e",
},
},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ser, err := tt.txn.EncodeSkycoinTransaction()
require.NoError(t, err)
exp, err := serializeCreatedTransaction(tt.txn)
require.NoError(t, err)
require.Equal(t, exp, ser)
})
}
}

0 comments on commit 49f3717

Please sign in to comment.