forked from TrueCloudLab/neoneo-go
65503aa9b4
1. Closes #840: added Nonce field to transaction.Transaction and removed Nonce field from transaction.MinerTx 2. Added following methods to different tx types: - NewMinerTx() - NewMinerTxWithNonce(...) - NewEnrollmentTx(...) - NewIssueTx() - NewPublishTx(...) - NewRegisterTx(...) - NewStateTx(...) in order to avoid code duplication when new transaction is created. 3. Commented out test cases where binary transaction/block are used. These test cases marked with `TODO NEO3.0: Update binary` and need to be updated. 4. Updated other tests 5. Added constant Nonce to GoveringTockenTx, UtilityTokenTx and genesis block to avoid data variability. Also marked with TODO.
26 lines
876 B
Go
26 lines
876 B
Go
package transaction
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestEncodeDecodeMiner(t *testing.T) {
|
|
// transaction from mainnet a1f219dc6be4c35eca172e65e02d4591045220221b1543f1a4b67b9e9442c264
|
|
rawtx := "0000fcd30e22000001e72d286979ee6cb1b7e65dfddfb2e384100b8d148e7758de42e4168b71792c60c8000000000000001f72e68b4e39602912106d53b229378a082784b200"
|
|
tx := decodeTransaction(rawtx, t)
|
|
assert.Equal(t, MinerType, tx.Type)
|
|
assert.IsType(t, tx.Data, &MinerTX{})
|
|
assert.Equal(t, 0, int(tx.Version))
|
|
assert.Equal(t, uint32(571397116), tx.Nonce)
|
|
|
|
assert.Equal(t, "a1f219dc6be4c35eca172e65e02d4591045220221b1543f1a4b67b9e9442c264", tx.Hash().StringLE())
|
|
|
|
// Encode
|
|
data, err := testserdes.EncodeBinary(tx)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, rawtx, hex.EncodeToString(data))
|
|
}
|