core: calcultate NEO owner on-the-fly

This commit is contained in:
Evgenii Stratonikov 2020-04-21 18:09:34 +03:00
parent be5389e8dd
commit 351fdd469f
2 changed files with 8 additions and 14 deletions

View file

@ -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
}
}

View file

@ -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
}