From 868c9d6e8cf6b4133ab0eece1d02aeab5eece33a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 30 Aug 2019 18:53:26 +0300 Subject: [PATCH] transaction: add miner tx test from dev --- .../core}/transaction/miner_test.go | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) rename {_pkg.dev/wire/payload => pkg/core}/transaction/miner_test.go (61%) diff --git a/_pkg.dev/wire/payload/transaction/miner_test.go b/pkg/core/transaction/miner_test.go similarity index 61% rename from _pkg.dev/wire/payload/transaction/miner_test.go rename to pkg/core/transaction/miner_test.go index fa22ebcd4..b26096ba5 100644 --- a/_pkg.dev/wire/payload/transaction/miner_test.go +++ b/pkg/core/transaction/miner_test.go @@ -5,33 +5,26 @@ import ( "encoding/hex" "testing" - "github.com/CityOfZion/neo-go/pkg/wire/payload/transaction/types" "github.com/stretchr/testify/assert" ) func TestEncodeDecodeMiner(t *testing.T) { // transaction from mainnet a1f219dc6be4c35eca172e65e02d4591045220221b1543f1a4b67b9e9442c264 - rawtx := "0000fcd30e22000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c60c8000000000000001f72e68b4e39602912106d53b229378a082784b200" - rawtxBytes, _ := hex.DecodeString(rawtx) - - m := NewMiner(0) - - r := bytes.NewReader(rawtxBytes) - err := m.Decode(r) - assert.Equal(t, nil, err) - - assert.Equal(t, types.Miner, m.Type) + tx := decodeTransaction(rawtx, t) + assert.Equal(t, MinerType, tx.Type) + assert.IsType(t, tx.Data, &MinerTX{}) + assert.Equal(t, 0, int(tx.Version)) + m := tx.Data.(*MinerTX) assert.Equal(t, uint32(571397116), m.Nonce) - assert.Equal(t, "a1f219dc6be4c35eca172e65e02d4591045220221b1543f1a4b67b9e9442c264", m.Hash.ReverseString()) + assert.Equal(t, "a1f219dc6be4c35eca172e65e02d4591045220221b1543f1a4b67b9e9442c264", tx.Hash().ReverseString()) // Encode buf := new(bytes.Buffer) - err = m.Encode(buf) + err := tx.EncodeBinary(buf) assert.Equal(t, nil, err) - assert.Equal(t, rawtxBytes, buf.Bytes()) - + assert.Equal(t, rawtx, hex.EncodeToString(buf.Bytes())) }