transaction: drop Gas field from InvocationTX

It essentialy is the new SystemFee, so use that. Had to increase GAS transfer
in test chain to 1000 to pay for deployment.
This commit is contained in:
Roman Khimov 2020-05-27 23:32:19 +03:00
parent 30c74152ce
commit d9400800e3
10 changed files with 19 additions and 76 deletions

View file

@ -735,7 +735,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
v.LoadScript(t.Script) v.LoadScript(t.Script)
v.SetPriceGetter(getPrice) v.SetPriceGetter(getPrice)
if bc.config.FreeGasLimit > 0 { if bc.config.FreeGasLimit > 0 {
v.SetGasLimit(bc.config.FreeGasLimit + t.Gas) v.SetGasLimit(bc.config.FreeGasLimit + tx.SystemFee)
} }
err := v.Run() err := v.Run()
@ -1401,11 +1401,6 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e
if err := bc.verifyClaims(t, results); err != nil { if err := bc.verifyClaims(t, results); err != nil {
return err return err
} }
case transaction.InvocationType:
inv := t.Data.(*transaction.InvocationTX)
if inv.Gas.FractionalValue() != 0 {
return errors.New("invocation gas can only be integer")
}
} }
return bc.verifyTxWitnesses(t, block) return bc.verifyTxWitnesses(t, block)

View file

@ -178,7 +178,7 @@ func TestCreateBasicChain(t *testing.T) {
require.Equal(t, util.Fixed8FromInt64(0), bc.GetUtilityTokenBalance(priv0ScriptHash)) require.Equal(t, util.Fixed8FromInt64(0), bc.GetUtilityTokenBalance(priv0ScriptHash))
// Move almost all NEO and some nep5 GAS to one simple account. // Move almost all NEO and some nep5 GAS to one simple account.
txMoveNeo := newNEP5Transfer(gasHash, neoOwner, priv0ScriptHash, 1000000000) txMoveNeo := newNEP5Transfer(gasHash, neoOwner, priv0ScriptHash, int64(util.Fixed8FromInt64(1000)))
txMoveNeo.ValidUntilBlock = validUntilBlock txMoveNeo.ValidUntilBlock = validUntilBlock
txMoveNeo.Nonce = getNextNonce() txMoveNeo.Nonce = getNextNonce()
txMoveNeo.Sender = neoOwner txMoveNeo.Sender = neoOwner
@ -215,7 +215,7 @@ func TestCreateBasicChain(t *testing.T) {
require.NoError(t, bc.AddBlock(b)) require.NoError(t, bc.AddBlock(b))
t.Logf("txMoveNeo: %s", txMoveNeo.Hash().StringLE()) t.Logf("txMoveNeo: %s", txMoveNeo.Hash().StringLE())
require.Equal(t, util.Fixed8FromInt64(10), bc.GetUtilityTokenBalance(priv0ScriptHash)) require.Equal(t, util.Fixed8FromInt64(1000), bc.GetUtilityTokenBalance(priv0ScriptHash))
// info for getblockheader rpc tests // info for getblockheader rpc tests
t.Logf("header hash: %s", b.Hash().StringLE()) t.Logf("header hash: %s", b.Hash().StringLE())
buf := io.NewBufBinWriter() buf := io.NewBufBinWriter()

View file

@ -13,10 +13,6 @@ import (
type InvocationTX struct { type InvocationTX struct {
// Script output of the smart contract. // Script output of the smart contract.
Script []byte Script []byte
// Gas cost of the smart contract.
Gas util.Fixed8
Version uint8
} }
// NewInvocationTX returns a new invocation transaction. // NewInvocationTX returns a new invocation transaction.
@ -26,10 +22,9 @@ func NewInvocationTX(script []byte, gas util.Fixed8) *Transaction {
Version: 1, Version: 1,
Nonce: rand.Uint32(), Nonce: rand.Uint32(),
Data: &InvocationTX{ Data: &InvocationTX{
Script: script, Script: script,
Gas: gas,
Version: 1,
}, },
SystemFee: gas,
Attributes: []Attribute{}, Attributes: []Attribute{},
Cosigners: []Cosigner{}, Cosigners: []Cosigner{},
Inputs: []Input{}, Inputs: []Input{},
@ -45,21 +40,9 @@ func (tx *InvocationTX) DecodeBinary(br *io.BinReader) {
br.Err = errors.New("no script") br.Err = errors.New("no script")
return return
} }
if tx.Version >= 1 {
tx.Gas.DecodeBinary(br)
if br.Err == nil && tx.Gas.LessThan(0) {
br.Err = errors.New("negative gas")
return
}
} else {
tx.Gas = util.Fixed8FromInt64(0)
}
} }
// EncodeBinary implements Serializable interface. // EncodeBinary implements Serializable interface.
func (tx *InvocationTX) EncodeBinary(bw *io.BinWriter) { func (tx *InvocationTX) EncodeBinary(bw *io.BinWriter) {
bw.WriteVarBytes(tx.Script) bw.WriteVarBytes(tx.Script)
if tx.Version >= 1 {
tx.Gas.EncodeBinary(bw)
}
} }

View file

@ -5,7 +5,6 @@ import (
"testing" "testing"
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes" "github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -15,7 +14,7 @@ func TestInvocationZeroScript(t *testing.T) {
in, err := hex.DecodeString("000000000000000000") in, err := hex.DecodeString("000000000000000000")
require.NoError(t, err) require.NoError(t, err)
inv := &InvocationTX{Version: 1} inv := &InvocationTX{}
assert.Error(t, testserdes.DecodeBinary(in, inv)) assert.Error(t, testserdes.DecodeBinary(in, inv))
// PUSH1 script. // PUSH1 script.
@ -24,31 +23,3 @@ func TestInvocationZeroScript(t *testing.T) {
assert.NoError(t, testserdes.DecodeBinary(in, inv)) assert.NoError(t, testserdes.DecodeBinary(in, inv))
} }
func TestInvocationNegativeGas(t *testing.T) {
// Negative GAS
in, err := hex.DecodeString("015100000000000000ff")
require.NoError(t, err)
inv := &InvocationTX{Version: 1}
assert.Error(t, testserdes.DecodeBinary(in, inv))
// Positive GAS.
in, err = hex.DecodeString("01510100000000000000")
require.NoError(t, err)
assert.NoError(t, testserdes.DecodeBinary(in, inv))
assert.Equal(t, util.Fixed8(1), inv.Gas)
}
func TestInvocationVersionZero(t *testing.T) {
in, err := hex.DecodeString("0151")
require.NoError(t, err)
inv := &InvocationTX{Version: 1}
assert.Error(t, testserdes.DecodeBinary(in, inv))
inv = &InvocationTX{Version: 0}
assert.NoError(t, testserdes.DecodeBinary(in, inv))
assert.Equal(t, util.Fixed8(0), inv.Gas)
}

View file

@ -174,7 +174,7 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) {
func (t *Transaction) decodeData(r *io.BinReader) { func (t *Transaction) decodeData(r *io.BinReader) {
switch t.Type { switch t.Type {
case InvocationType: case InvocationType:
t.Data = &InvocationTX{Version: t.Version} t.Data = &InvocationTX{}
t.Data.(*InvocationTX).DecodeBinary(r) t.Data.(*InvocationTX).DecodeBinary(r)
case ClaimType: case ClaimType:
t.Data = &ClaimTX{} t.Data = &ClaimTX{}
@ -315,7 +315,6 @@ type transactionJSON struct {
Claims []Input `json:"claims,omitempty"` Claims []Input `json:"claims,omitempty"`
Script string `json:"script,omitempty"` Script string `json:"script,omitempty"`
Gas util.Fixed8 `json:"gas,omitempty"`
Asset *registeredAsset `json:"asset,omitempty"` Asset *registeredAsset `json:"asset,omitempty"`
} }
@ -342,7 +341,6 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
tx.Claims = t.Data.(*ClaimTX).Claims tx.Claims = t.Data.(*ClaimTX).Claims
case InvocationType: case InvocationType:
tx.Script = hex.EncodeToString(t.Data.(*InvocationTX).Script) tx.Script = hex.EncodeToString(t.Data.(*InvocationTX).Script)
tx.Gas = t.Data.(*InvocationTX).Gas
case RegisterType: case RegisterType:
transaction := *t.Data.(*RegisterTX) transaction := *t.Data.(*RegisterTX)
tx.Asset = &registeredAsset{ tx.Asset = &registeredAsset{
@ -390,9 +388,7 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
return err return err
} }
t.Data = &InvocationTX{ t.Data = &InvocationTX{
Script: bytes, Script: bytes,
Gas: tx.Gas,
Version: tx.Version,
} }
case RegisterType: case RegisterType:
admin, err := address.StringToUint160(tx.Asset.Admin) admin, err := address.StringToUint160(tx.Asset.Admin)

View file

@ -92,7 +92,7 @@ func TestNewInvocationTX(t *testing.T) {
tx := NewInvocationTX(script, 1) tx := NewInvocationTX(script, 1)
txData := tx.Data.(*InvocationTX) txData := tx.Data.(*InvocationTX)
assert.Equal(t, InvocationType, tx.Type) assert.Equal(t, InvocationType, tx.Type)
assert.Equal(t, tx.Version, txData.Version) assert.Equal(t, util.Fixed8(1), tx.SystemFee)
assert.Equal(t, script, txData.Script) assert.Equal(t, script, txData.Script)
// Update hash fields to match tx2 that is gonna autoupdate them on decode. // Update hash fields to match tx2 that is gonna autoupdate them on decode.
_ = tx.Hash() _ = tx.Hash()
@ -153,9 +153,7 @@ func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) {
Type: InvocationType, Type: InvocationType,
Version: 3, Version: 3,
Data: &InvocationTX{ Data: &InvocationTX{
Script: []byte{1, 2, 3, 4}, Script: []byte{1, 2, 3, 4},
Gas: util.Fixed8FromFloat(100),
Version: 3,
}, },
Attributes: []Attribute{}, Attributes: []Attribute{},
Inputs: []Input{{ Inputs: []Input{{

View file

@ -20,7 +20,7 @@ func TestGenesisBlockMainNet(t *testing.T) {
// have been changed. Consequently, hash of the genesis block has been changed. // have been changed. Consequently, hash of the genesis block has been changed.
// Update expected genesis block hash for better times. // Update expected genesis block hash for better times.
// Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf" // Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf"
expect := "1d4156d233220b893797a684fbb827bb2163b5042edd10653bbc1b2769adbb8d" expect := "472edea0e91369b51903b364e7403492a9041536fbfe145a9e1aff0ad5f18d78"
assert.Equal(t, expect, block.Hash().StringLE()) assert.Equal(t, expect, block.Hash().StringLE())
} }

View file

@ -117,8 +117,8 @@ func TestWSClientEvents(t *testing.T) {
var events = []string{ var events = []string{
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","executions":[{"trigger":"Application","contract":"0x0000000000000000000000000000000000000000","vmstate":"HALT","gas_consumed":"2.291","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"7472616e73666572"},{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}}]}]}]}`, `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","executions":[{"trigger":"Application","contract":"0x0000000000000000000000000000000000000000","vmstate":"HALT","gas_consumed":"2.291","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"7472616e73666572"},{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}}]}]}]}`,
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}}]}`, `{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}}]}`,
`{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","size":277,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0037721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4027727296b84853c5d9e07fb8a40e885246ae25641383b16eefbe92027ecb1635b794aacf6bbfc3e828c73829b14791c483d19eb758b57638e3191393dbf2d288","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}`, `{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}`,
`{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x239fea00c54c2f6812612874183b72bef4473fcdf68bf8da08d74fd5b6cab030","version":0,"previousblockhash":"0x04f7580b111ec75f0ce68d3a9fd70a0544b4521b4a98541694d8575c548b759e","merkleroot":"0xb2c7230ebee4cb83bc03afadbba413e6bca8fcdeaf9c077bea060918da0e52a1","time":1590006200,"index":207,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c4063429fca5ff75c964d9e38179c75978e33f8174d91a780c2e825265cf2447281594afdd5f3e216dcaf5ff0693aec83f415996cf224454495495f6bd0a4c5d08f0c4099680903a954278580d8533121c2cd3e53a089817b6a784901ec06178a60b5f1da6e70422bdcadc89029767e08d66ce4180b99334cb2d42f42e4216394af15920c4067d5e362189e48839a24e187c59d46f5d9db862c8a029777f1548b19632bfdc73ad373827ed02369f925e89c2303b64e6b9838dca229949b9b9d3bd4c0c3ed8f0c4021d4c00d4522805883f1db929554441bcbbee127c48f6b7feeeb69a72a78c7f0a75011663e239c0820ef903f36168f42936de10f0ef20681cb735a4b53d0390f","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xf736cd91ab84062a21a09b424346b241987f6245ffe8c2b2db39d595c3c222f7","size":204,"type":"InvocationTransaction","version":1,"nonce":8,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0030421","valid_until_block":1200,"attributes":[],"cosigners":[],"vin":[],"vout":[],"scripts":[{"invocation":"0c4016e7a112742409cdfaad89dcdbcb52c94c5c1a69dfe5d8b999649eaaa787e31ca496d1734d6ea606c749ad36e9a88892240ae59e0efa7f544e0692124898d512","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"10c00c04696e69740c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b52"},{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","size":277,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0037721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4027727296b84853c5d9e07fb8a40e885246ae25641383b16eefbe92027ecb1635b794aacf6bbfc3e828c73829b14791c483d19eb758b57638e3191393dbf2d288","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}]}`, `{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x3c99815f393807efd7a620a04eed66440a3c89d41ff18fd42c08f71784fc1c16","version":0,"previousblockhash":"0xb6533ac10e71fb02348af87c0a723131939ee08713a7f31075d24beb54100f1a","merkleroot":"0x7470df300c48107d36ffd3da09b155a35650f1020d019abb0c3abb7bf91a09e2","time":1590609889,"index":207,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c4095dfc789359ca154c07f1bfdc28e0ac512f78156825efafd9b31a6a8009cef6339de6f8331aad35f6dc8af9a7723a07fb9319ccad54c91ab9be155964efa5f920c4067ac11066db9e47f64cf876e3d6dd07e28324d51b53faf2a42ccafc371050efbe0b5809c80672ea116a557bfbdbf789b7bca008064834db80c7c91a768bcec760c40aefd42910ad6a6f9c3ba17a5b38e8de7188d0b36972c47d3054715209ca79d9811beff9a762ebd1c78584ff3110222419b2cdba6c22bbcbb554195bf9df09bb30c40368c314b35b051a4a258828d3327e8c22053166eeb749d50a9a33e2620ba156042124979a1554524daf9f7b371ec0da5b41404a1b5e0d42fe0032859e114833c","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xde4481fdbef5d3726d0052661f950e69e4594dd6589913c628e20c1413f85b74","size":196,"type":"InvocationTransaction","version":1,"nonce":8,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0029621","valid_until_block":1200,"attributes":[],"cosigners":[],"vin":[],"vout":[],"scripts":[{"invocation":"0c40b192490537d5ec2c747fdf6ad8d73d0e3aae105c3d9ed96e7e032b28018fa54996661b17aaa107adc7a73a8ca3916b61a4b2b673e1b2a30c3c7117a01cf937a1","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"10c00c04696e69740c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b52"},{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}]}`,
`{"jsonrpc":"2.0","method":"event_missed","params":[]}`, `{"jsonrpc":"2.0","method":"event_missed","params":[]}`,
} }
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {

View file

@ -54,12 +54,12 @@ var rpcTestCases = map[string][]rpcTestCase{
"getapplicationlog": { "getapplicationlog": {
{ {
name: "positive", name: "positive",
params: `["0a0abf0188053113d0014e0cb9801d090a5d3e7640d76427fa1a3676e7cdf82e"]`, params: `["1e71f60519a68c73cc1ca5382bab12160c4967c86e28e8238b78ea54dcbdc716"]`,
result: func(e *executor) interface{} { return &result.ApplicationLog{} }, result: func(e *executor) interface{} { return &result.ApplicationLog{} },
check: func(t *testing.T, e *executor, acc interface{}) { check: func(t *testing.T, e *executor, acc interface{}) {
res, ok := acc.(*result.ApplicationLog) res, ok := acc.(*result.ApplicationLog)
require.True(t, ok) require.True(t, ok)
expectedTxHash, err := util.Uint256DecodeStringLE("0a0abf0188053113d0014e0cb9801d090a5d3e7640d76427fa1a3676e7cdf82e") expectedTxHash, err := util.Uint256DecodeStringLE("1e71f60519a68c73cc1ca5382bab12160c4967c86e28e8238b78ea54dcbdc716")
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, expectedTxHash, res.TxHash) assert.Equal(t, expectedTxHash, res.TxHash)
assert.Equal(t, 1, len(res.Executions)) assert.Equal(t, 1, len(res.Executions))
@ -180,7 +180,7 @@ var rpcTestCases = map[string][]rpcTestCase{
}, },
{ {
Asset: e.chain.UtilityTokenHash(), Asset: e.chain.UtilityTokenHash(),
Amount: "10", Amount: "1000",
LastUpdated: 1, LastUpdated: 1,
}}, }},
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(), Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
@ -247,7 +247,7 @@ var rpcTestCases = map[string][]rpcTestCase{
Timestamp: blockRecieveGAS.Timestamp, Timestamp: blockRecieveGAS.Timestamp,
Asset: e.chain.UtilityTokenHash(), Asset: e.chain.UtilityTokenHash(),
Address: testchain.MultisigAddress(), Address: testchain.MultisigAddress(),
Amount: "10", Amount: "1000",
Index: 1, Index: 1,
NotifyIndex: 0, NotifyIndex: 0,
TxHash: txRecieveGASHash, TxHash: txRecieveGASHash,
@ -579,7 +579,7 @@ var rpcTestCases = map[string][]rpcTestCase{
"gettransactionheight": { "gettransactionheight": {
{ {
name: "positive", name: "positive",
params: `["0e873d5d565a03c6cd39efa3b446e1901b4636c448a22bc7e8c259c5a28a2eda"]`, params: `["be463055a8447567434037aad40ad58764cb7eef4aee64308f74ce6df5a98a8a"]`,
result: func(e *executor) interface{} { result: func(e *executor) interface{} {
h := 1 h := 1
return &h return &h
@ -791,7 +791,7 @@ var rpcTestCases = map[string][]rpcTestCase{
"sendrawtransaction": { "sendrawtransaction": {
{ {
name: "positive", name: "positive",
params: `["80000b000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000a267050000000000b00400000000017a03a89832a347c4fb53af1f526d0d930b14ab6eb01629ce20ffbaeaeef58af3010001787cc0a786adfe829bc2dffc5637e6855c0a82e02deee97dedbc2aac3e0e5e1a0030d3dec3862300316e851039019d39dfc2c37d6c3fee19fd58098701420c40b6aeec1d2699194b842f399448b395d98bbb287dc89ea9e5ce3bb99a1c8c9bf933f55b69db6709b44e6a5c8b28b97018466479e5d500e414a0874c37abab262d290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`, params: `["80000b000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000a267050000000000b0040000000001e2b5b6f72dc08d3b0e498c6466928031333f0b242cf158a547b8c4a1681f8f2d010001787cc0a786adfe829bc2dffc5637e6855c0a82e02deee97dedbc2aac3e0e5e1a0030d3dec3862300316e851039019d39dfc2c37d6c3fee19fd58098701420c406a41c10280ff445c36fb16fe94fa197c9ab9678d099c7c1af5d4b9269ac19bbba09e20f02f53582bc340b4ea77539c28bb2cc03902e77d5d37febabe902aac98290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`,
result: func(e *executor) interface{} { result: func(e *executor) interface{} {
v := true v := true
return &v return &v

Binary file not shown.