From 351fdd469fa020ed33ba97840c051187e5b82517 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 21 Apr 2020 18:09:34 +0300 Subject: [PATCH] core: calcultate NEO owner on-the-fly --- pkg/consensus/consensus_test.go | 6 +++--- pkg/core/helper_test.go | 16 +++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/pkg/consensus/consensus_test.go b/pkg/consensus/consensus_test.go index f8da39be3..9e1cf7216 100644 --- a/pkg/consensus/consensus_test.go +++ b/pkg/consensus/consensus_test.go @@ -240,11 +240,11 @@ func (fs *feer) IsLowPriority(util.Fixed8) bool { return false func (fs *feer) FeePerByte(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) } func (fs *feer) SystemFee(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) } +var neoOwner = testchain.MultisigScriptHash() + func addSender(t *testing.T, txs ...*transaction.Transaction) { - // multisig address which possess all NEO - scriptHash := testchain.MultisigScriptHash() for _, tx := range txs { - tx.Sender = scriptHash + tx.Sender = neoOwner } } diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 68fc1ec8e..773a40b8c 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -29,7 +29,7 @@ import ( ) // multisig address which possess all NEO -var neoOwner = testchain.MultisigScriptHash().StringBE() +var neoOwner = testchain.MultisigScriptHash() // newTestChain should be called before newBlock invocation to properly setup // global state. @@ -211,9 +211,7 @@ func TestCreateBasicChain(t *testing.T) { PrevIndex: 0, }) - scriptHash, err := util.Uint160DecodeStringBE(neoOwner) - require.NoError(t, err) - txMoveNeo.Sender = scriptHash + txMoveNeo.Sender = neoOwner priv0 := testchain.PrivateKeyByID(0) priv0ScriptHash := priv0.GetScriptHash() @@ -226,13 +224,13 @@ func TestCreateBasicChain(t *testing.T) { txMoveNeo.AddOutput(&transaction.Output{ AssetID: GoverningTokenID(), Amount: neoRemainder, - ScriptHash: scriptHash, + ScriptHash: neoOwner, Position: 1, }) txMoveNeo.Data = new(transaction.ContractTX) minerTx := nextMinerTx(validUntilBlock) - minerTx.Sender = scriptHash + minerTx.Sender = neoOwner require.NoError(t, signTx(bc, minerTx, txMoveNeo)) b := bc.newBlock(minerTx, txMoveNeo) @@ -492,12 +490,8 @@ func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Trans } func addSender(txs ...*transaction.Transaction) error { - scriptHash, err := util.Uint160DecodeStringBE(neoOwner) - if err != nil { - return errors.Wrap(err, "can't add sender to tx") - } for _, tx := range txs { - tx.Sender = scriptHash + tx.Sender = neoOwner } return nil }