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) FeePerByte(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) }
func (fs *feer) SystemFee(*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) { func addSender(t *testing.T, txs ...*transaction.Transaction) {
// multisig address which possess all NEO
scriptHash := testchain.MultisigScriptHash()
for _, tx := range txs { for _, tx := range txs {
tx.Sender = scriptHash tx.Sender = neoOwner
} }
} }

View file

@ -29,7 +29,7 @@ import (
) )
// multisig address which possess all NEO // 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 // newTestChain should be called before newBlock invocation to properly setup
// global state. // global state.
@ -211,9 +211,7 @@ func TestCreateBasicChain(t *testing.T) {
PrevIndex: 0, PrevIndex: 0,
}) })
scriptHash, err := util.Uint160DecodeStringBE(neoOwner) txMoveNeo.Sender = neoOwner
require.NoError(t, err)
txMoveNeo.Sender = scriptHash
priv0 := testchain.PrivateKeyByID(0) priv0 := testchain.PrivateKeyByID(0)
priv0ScriptHash := priv0.GetScriptHash() priv0ScriptHash := priv0.GetScriptHash()
@ -226,13 +224,13 @@ func TestCreateBasicChain(t *testing.T) {
txMoveNeo.AddOutput(&transaction.Output{ txMoveNeo.AddOutput(&transaction.Output{
AssetID: GoverningTokenID(), AssetID: GoverningTokenID(),
Amount: neoRemainder, Amount: neoRemainder,
ScriptHash: scriptHash, ScriptHash: neoOwner,
Position: 1, Position: 1,
}) })
txMoveNeo.Data = new(transaction.ContractTX) txMoveNeo.Data = new(transaction.ContractTX)
minerTx := nextMinerTx(validUntilBlock) minerTx := nextMinerTx(validUntilBlock)
minerTx.Sender = scriptHash minerTx.Sender = neoOwner
require.NoError(t, signTx(bc, minerTx, txMoveNeo)) require.NoError(t, signTx(bc, minerTx, txMoveNeo))
b := bc.newBlock(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 { 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 { for _, tx := range txs {
tx.Sender = scriptHash tx.Sender = neoOwner
} }
return nil return nil
} }