forked from TrueCloudLab/neoneo-go
parent
591a1b900d
commit
2b5c14160c
15 changed files with 305 additions and 99 deletions
|
@ -269,6 +269,7 @@ func claimGas(ctx *cli.Context) error {
|
|||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
tx.ValidUntilBlock = validUntilBlock
|
||||
tx.Sender = scriptHash
|
||||
|
||||
tx.AddOutput(&transaction.Output{
|
||||
AssetID: core.UtilityTokenID(),
|
||||
|
@ -523,6 +524,7 @@ func transferAsset(ctx *cli.Context) error {
|
|||
if err := request.AddInputsAndUnspentsToTx(tx, fromFlag.String(), asset, amount, c); err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
tx.Sender = from
|
||||
|
||||
toFlag := ctx.Generic("to").(*flags.Address)
|
||||
if !toFlag.IsSet {
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
@ -25,6 +26,8 @@ func TestNewService(t *testing.T) {
|
|||
srv := newTestService(t)
|
||||
tx := transaction.NewMinerTX()
|
||||
tx.ValidUntilBlock = 1
|
||||
addSender(t, tx)
|
||||
signTx(t, tx)
|
||||
require.NoError(t, srv.Chain.PoolTx(tx))
|
||||
|
||||
var txx []block.Transaction
|
||||
|
@ -42,6 +45,8 @@ func TestService_GetVerified(t *testing.T) {
|
|||
tx.ValidUntilBlock = 1
|
||||
txs = append(txs, tx)
|
||||
}
|
||||
addSender(t, txs...)
|
||||
signTx(t, txs...)
|
||||
require.NoError(t, srv.Chain.PoolTx(txs[3]))
|
||||
|
||||
hashes := []util.Uint256{txs[0].Hash(), txs[1].Hash(), txs[2].Hash()}
|
||||
|
@ -116,6 +121,8 @@ func TestService_getTx(t *testing.T) {
|
|||
t.Run("transaction in mempool", func(t *testing.T) {
|
||||
tx := transaction.NewMinerTXWithNonce(1234)
|
||||
tx.ValidUntilBlock = 1
|
||||
addSender(t, tx)
|
||||
signTx(t, tx)
|
||||
h := tx.Hash()
|
||||
|
||||
require.Equal(t, nil, srv.getTx(h))
|
||||
|
@ -259,3 +266,38 @@ func (fs *feer) NetworkFee(*transaction.Transaction) util.Fixed8 { return util.F
|
|||
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) }
|
||||
|
||||
func addSender(t *testing.T, txs ...*transaction.Transaction) {
|
||||
// multisig address which possess all NEO
|
||||
scriptHash, err := util.Uint160DecodeStringBE("d60ac443bb800fb08261e75fa5925d747d485861")
|
||||
require.NoError(t, err)
|
||||
for _, tx := range txs {
|
||||
tx.Sender = scriptHash
|
||||
}
|
||||
}
|
||||
|
||||
func signTx(t *testing.T, txs ...*transaction.Transaction) {
|
||||
validators := make([]*keys.PublicKey, 4)
|
||||
privNetKeys := make([]*keys.PrivateKey, 4)
|
||||
for i := 0; i < 4; i++ {
|
||||
privateKey, publicKey := getTestValidator(i)
|
||||
validators[i] = publicKey.PublicKey
|
||||
privNetKeys[i] = privateKey.PrivateKey
|
||||
}
|
||||
rawScript, err := smartcontract.CreateMultiSigRedeemScript(3, validators)
|
||||
require.NoError(t, err)
|
||||
for _, tx := range txs {
|
||||
data := tx.GetSignedPart()
|
||||
|
||||
var invoc []byte
|
||||
for _, key := range privNetKeys {
|
||||
signature := key.Sign(data)
|
||||
invoc = append(invoc, append([]byte{byte(opcode.PUSHBYTES64)}, signature...)...)
|
||||
}
|
||||
|
||||
tx.Scripts = []transaction.Witness{{
|
||||
InvocationScript: invoc,
|
||||
VerificationScript: rawScript,
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1868,6 +1868,7 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
|
|||
}
|
||||
}
|
||||
}
|
||||
hashes[t.Sender] = true
|
||||
switch t.Type {
|
||||
case transaction.ClaimType:
|
||||
claim := t.Data.(*transaction.ClaimTX)
|
||||
|
|
|
@ -99,6 +99,8 @@ func TestGetHeader(t *testing.T) {
|
|||
bc := newTestChain(t)
|
||||
tx := transaction.NewMinerTX()
|
||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||
assert.Nil(t, addSender(tx))
|
||||
assert.Nil(t, signTx(bc, tx))
|
||||
block := bc.newBlock(tx)
|
||||
err := bc.AddBlock(block)
|
||||
assert.Nil(t, err)
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
@ -33,6 +34,9 @@ var privNetKeys = []string{
|
|||
"L2oEXKRAAMiPEZukwR5ho2S6SMeQLhcK9mF71ZnF7GvT8dU4Kkgz",
|
||||
}
|
||||
|
||||
// multisig address which possess all NEO
|
||||
var neoOwner = "d60ac443bb800fb08261e75fa5925d747d485861"
|
||||
|
||||
// newTestChain should be called before newBlock invocation to properly setup
|
||||
// global state.
|
||||
func newTestChain(t *testing.T) *Blockchain {
|
||||
|
@ -98,6 +102,14 @@ func (bc *Blockchain) genBlocks(n int) ([]*block.Block, error) {
|
|||
for i := 0; i < n; i++ {
|
||||
minerTx := transaction.NewMinerTXWithNonce(uint32(1234 + i))
|
||||
minerTx.ValidUntilBlock = lastIndex + uint32(i) + 1
|
||||
err := addSender(minerTx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = signTx(bc, minerTx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blocks[i] = newBlock(bc.config, uint32(i)+lastIndex+1, lastHash, minerTx)
|
||||
if err := bc.AddBlock(blocks[i]); err != nil {
|
||||
return blocks, err
|
||||
|
@ -207,11 +219,13 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
PrevIndex: 0,
|
||||
})
|
||||
|
||||
// multisig address which possess all NEO
|
||||
scriptHash, err := util.Uint160DecodeStringBE("d60ac443bb800fb08261e75fa5925d747d485861")
|
||||
scriptHash, err := util.Uint160DecodeStringBE(neoOwner)
|
||||
require.NoError(t, err)
|
||||
txMoveNeo.Sender = scriptHash
|
||||
|
||||
priv0, err := keys.NewPrivateKeyFromWIF(privNetKeys[0])
|
||||
require.NoError(t, err)
|
||||
priv0ScriptHash := priv0.GetScriptHash()
|
||||
txMoveNeo.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoAmount,
|
||||
|
@ -226,24 +240,11 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
})
|
||||
txMoveNeo.Data = new(transaction.ContractTX)
|
||||
|
||||
validators, err := getValidators(bc.config)
|
||||
require.NoError(t, err)
|
||||
rawScript, err := smartcontract.CreateMultiSigRedeemScript(len(bc.config.StandbyValidators)/2+1, validators)
|
||||
require.NoError(t, err)
|
||||
data := txMoveNeo.GetSignedPart()
|
||||
minerTx := nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = scriptHash
|
||||
|
||||
var invoc []byte
|
||||
for i := range privNetKeys {
|
||||
priv, err := keys.NewPrivateKeyFromWIF(privNetKeys[i])
|
||||
require.NoError(t, err)
|
||||
invoc = append(invoc, getInvocationScript(data, priv)...)
|
||||
}
|
||||
|
||||
txMoveNeo.Scripts = []transaction.Witness{{
|
||||
InvocationScript: invoc,
|
||||
VerificationScript: rawScript,
|
||||
}}
|
||||
b := bc.newBlock(nextMinerTx(validUntilBlock), txMoveNeo)
|
||||
require.NoError(t, signTx(bc, minerTx, txMoveNeo))
|
||||
b := bc.newBlock(minerTx, txMoveNeo)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txMoveNeo: %s", txMoveNeo.Hash().StringLE())
|
||||
|
||||
|
@ -263,6 +264,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
// Make a NEO roundtrip (send to myself) and claim GAS.
|
||||
txNeoRound := transaction.NewContractTX()
|
||||
txNeoRound.Nonce = getNextNonce()
|
||||
txNeoRound.Sender = priv0ScriptHash
|
||||
txNeoRound.ValidUntilBlock = validUntilBlock
|
||||
txNeoRound.AddInput(&transaction.Input{
|
||||
PrevHash: txMoveNeo.Hash(),
|
||||
|
@ -276,7 +278,10 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
})
|
||||
txNeoRound.Data = new(transaction.ContractTX)
|
||||
require.NoError(t, acc0.SignTx(txNeoRound))
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), txNeoRound)
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, txNeoRound)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txNeoRound: %s", txNeoRound.Hash().StringLE())
|
||||
|
||||
|
@ -288,6 +293,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txClaim := transaction.NewClaimTX(claim)
|
||||
txClaim.Nonce = getNextNonce()
|
||||
txClaim.ValidUntilBlock = validUntilBlock
|
||||
txClaim.Sender = priv0ScriptHash
|
||||
txClaim.Data = claim
|
||||
neoGas, sysGas, err := bc.CalculateClaimable(neoAmount, 1, bc.BlockHeight())
|
||||
require.NoError(t, err)
|
||||
|
@ -299,7 +305,10 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
Position: 0,
|
||||
})
|
||||
require.NoError(t, acc0.SignTx(txClaim))
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), txClaim)
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, txClaim)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txClaim: %s", txClaim.Hash().StringLE())
|
||||
|
||||
|
@ -329,6 +338,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txDeploy := transaction.NewInvocationTX(txScript, invFee)
|
||||
txDeploy.Nonce = getNextNonce()
|
||||
txDeploy.ValidUntilBlock = validUntilBlock
|
||||
txDeploy.Sender = priv0ScriptHash
|
||||
txDeploy.AddInput(&transaction.Input{
|
||||
PrevHash: txClaim.Hash(),
|
||||
PrevIndex: 0,
|
||||
|
@ -341,7 +351,10 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
})
|
||||
gasOwned -= invFee
|
||||
require.NoError(t, acc0.SignTx(txDeploy))
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), txDeploy)
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, txDeploy)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txDeploy: %s", txDeploy.Hash().StringLE())
|
||||
|
||||
|
@ -352,7 +365,12 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txInv := transaction.NewInvocationTX(script.Bytes(), 0)
|
||||
txInv.Nonce = getNextNonce()
|
||||
txInv.ValidUntilBlock = validUntilBlock
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), txInv)
|
||||
txInv.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(txInv))
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, txInv)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txInv: %s", txInv.Hash().StringLE())
|
||||
|
||||
|
@ -361,6 +379,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txNeo0to1 := transaction.NewContractTX()
|
||||
txNeo0to1.Nonce = getNextNonce()
|
||||
txNeo0to1.ValidUntilBlock = validUntilBlock
|
||||
txNeo0to1.Sender = priv0ScriptHash
|
||||
txNeo0to1.Data = new(transaction.ContractTX)
|
||||
txNeo0to1.AddInput(&transaction.Input{
|
||||
PrevHash: txNeoRound.Hash(),
|
||||
|
@ -378,7 +397,10 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
})
|
||||
|
||||
require.NoError(t, acc0.SignTx(txNeo0to1))
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), txNeo0to1)
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, txNeo0to1)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
|
||||
sh := hash.Hash160(avm)
|
||||
|
@ -387,17 +409,30 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
initTx := transaction.NewInvocationTX(w.Bytes(), 0)
|
||||
initTx.Nonce = getNextNonce()
|
||||
initTx.ValidUntilBlock = validUntilBlock
|
||||
initTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(initTx))
|
||||
transferTx := newNEP5Transfer(sh, sh, priv0.GetScriptHash(), 1000)
|
||||
transferTx.Nonce = getNextNonce()
|
||||
transferTx.ValidUntilBlock = validUntilBlock
|
||||
transferTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(transferTx))
|
||||
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), initTx, transferTx)
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, initTx, transferTx)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
|
||||
transferTx = newNEP5Transfer(sh, priv0.GetScriptHash(), priv1.GetScriptHash(), 123)
|
||||
transferTx.Nonce = getNextNonce()
|
||||
transferTx.ValidUntilBlock = validUntilBlock
|
||||
b = bc.newBlock(nextMinerTx(validUntilBlock), transferTx)
|
||||
transferTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(transferTx))
|
||||
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
b = bc.newBlock(minerTx, transferTx)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
|
||||
if saveChain {
|
||||
|
@ -426,6 +461,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txNeoRound = transaction.NewContractTX()
|
||||
txNeoRound.Nonce = getNextNonce()
|
||||
txNeoRound.ValidUntilBlock = validUntilBlock
|
||||
txNeoRound.Sender = priv0ScriptHash
|
||||
txNeoRound.AddInput(&transaction.Input{
|
||||
PrevHash: txNeo0to1.Hash(),
|
||||
PrevIndex: 1,
|
||||
|
@ -445,7 +481,10 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
// Blocks for `submitblock` test. If you are planning to modify test chain from `testblocks.acc`,
|
||||
// please, update params value of `empty block` and `positive` tests.
|
||||
var blocks []*block.Block
|
||||
blocks = append(blocks, bc.newBlock(), bc.newBlock(nextMinerTx(validUntilBlock)))
|
||||
minerTx = nextMinerTx(validUntilBlock)
|
||||
minerTx.Sender = priv0ScriptHash
|
||||
require.NoError(t, acc0.SignTx(minerTx))
|
||||
blocks = append(blocks, bc.newBlock(), bc.newBlock(minerTx))
|
||||
for i, b := range blocks {
|
||||
data, err := testserdes.EncodeBinary(b)
|
||||
require.NoError(t, err)
|
||||
|
@ -461,3 +500,43 @@ func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Trans
|
|||
script := w.Bytes()
|
||||
return transaction.NewInvocationTX(script, 0)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func signTx(bc *Blockchain, txs ...*transaction.Transaction) error {
|
||||
validators, err := getValidators(bc.config)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to sign tx")
|
||||
}
|
||||
rawScript, err := smartcontract.CreateMultiSigRedeemScript(len(bc.config.StandbyValidators)/2+1, validators)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to sign tx")
|
||||
}
|
||||
for _, tx := range txs {
|
||||
data := tx.GetSignedPart()
|
||||
|
||||
var invoc []byte
|
||||
for i := range privNetKeys {
|
||||
priv, err := keys.NewPrivateKeyFromWIF(privNetKeys[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
invoc = append(invoc, getInvocationScript(data, priv)...)
|
||||
}
|
||||
|
||||
tx.Scripts = []transaction.Witness{{
|
||||
InvocationScript: invoc,
|
||||
VerificationScript: rawScript,
|
||||
}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ func TestNativeContract_Invoke(t *testing.T) {
|
|||
validUntil := chain.blockHeight + 1
|
||||
tx.ValidUntilBlock = validUntil
|
||||
mn.ValidUntilBlock = validUntil
|
||||
require.NoError(t, addSender(tx, mn))
|
||||
require.NoError(t, signTx(chain, tx, mn))
|
||||
b := chain.newBlock(mn, tx)
|
||||
require.NoError(t, chain.AddBlock(b))
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ type Transaction struct {
|
|||
// Random number to avoid hash collision.
|
||||
Nonce uint32
|
||||
|
||||
// Address signed the transaction.
|
||||
Sender util.Uint160
|
||||
|
||||
// Maximum blockchain height exceeding which
|
||||
// transaction should fail verification.
|
||||
ValidUntilBlock uint32
|
||||
|
@ -118,6 +121,8 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
|||
t.Type = TXType(br.ReadB())
|
||||
t.Version = uint8(br.ReadB())
|
||||
t.Nonce = br.ReadU32LE()
|
||||
br.ReadBytes(t.Sender[:])
|
||||
|
||||
t.ValidUntilBlock = br.ReadU32LE()
|
||||
t.decodeData(br)
|
||||
|
||||
|
@ -187,6 +192,7 @@ func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
|||
bw.WriteB(byte(t.Type))
|
||||
bw.WriteB(byte(t.Version))
|
||||
bw.WriteU32LE(t.Nonce)
|
||||
bw.WriteBytes(t.Sender[:])
|
||||
bw.WriteU32LE(t.ValidUntilBlock)
|
||||
|
||||
// Underlying TXer.
|
||||
|
@ -268,6 +274,7 @@ type transactionJSON struct {
|
|||
Type TXType `json:"type"`
|
||||
Version uint8 `json:"version"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
Sender string `json:"sender"`
|
||||
ValidUntilBlock uint32 `json:"valid_until_block"`
|
||||
Attributes []Attribute `json:"attributes"`
|
||||
Inputs []Input `json:"vin"`
|
||||
|
@ -290,6 +297,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
|
|||
Type: t.Type,
|
||||
Version: t.Version,
|
||||
Nonce: t.Nonce,
|
||||
Sender: address.Uint160ToString(t.Sender),
|
||||
ValidUntilBlock: t.ValidUntilBlock,
|
||||
Attributes: t.Attributes,
|
||||
Inputs: t.Inputs,
|
||||
|
@ -334,6 +342,11 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
|
|||
t.Inputs = tx.Inputs
|
||||
t.Outputs = tx.Outputs
|
||||
t.Scripts = tx.Scripts
|
||||
sender, err := address.StringToUint160(tx.Sender)
|
||||
if err != nil {
|
||||
return errors.New("cannot unmarshal tx: bad sender")
|
||||
}
|
||||
t.Sender = sender
|
||||
switch tx.Type {
|
||||
case MinerType:
|
||||
t.Data = &MinerTX{}
|
||||
|
|
|
@ -59,10 +59,12 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
scriptOut := hash.Hash160(rawScript)
|
||||
|
||||
minerTx := transaction.NewMinerTXWithNonce(2083236893)
|
||||
minerTx.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
|
||||
issueTx := transaction.NewIssueTX()
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of genesis block
|
||||
issueTx.Nonce = 0
|
||||
issueTx.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
issueTx.Outputs = []transaction.Output{
|
||||
{
|
||||
AssetID: governingTokenTX.Hash(),
|
||||
|
@ -107,6 +109,7 @@ func init() {
|
|||
governingTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
governingTokenTX.Nonce = 0
|
||||
governingTokenTX.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
|
||||
admin = hash.Hash160([]byte{byte(opcode.PUSHF)})
|
||||
registerTX = &transaction.RegisterTX{
|
||||
|
@ -119,6 +122,7 @@ func init() {
|
|||
utilityTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
utilityTokenTX.Nonce = 0
|
||||
utilityTokenTX.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
}
|
||||
|
||||
// GoverningTokenID returns the governing token (NEO) hash.
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestGenesisBlockMainNet(t *testing.T) {
|
|||
// have been changed. Consequently, hash of the genesis block has been changed.
|
||||
// Update expected genesis block hash for better times.
|
||||
// Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf"
|
||||
expect := "75b6219158953816fbfe1884160f3fe0a4a4d0f7a2b7948bc89787d616f84983"
|
||||
expect := "8b247d93f1f2cba80f0908c65f94c74d17bbadefc27c7afdee5b5b078ed6ed55"
|
||||
assert.Equal(t, expect, block.Hash().StringLE())
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ func TestUtilityTokenTX(t *testing.T) {
|
|||
//TODO: After we added Nonce field to transaction.Transaction, UtilityTockenTx hash
|
||||
// has been changed. Update it for better times.
|
||||
// Old hash is "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"
|
||||
expect := "8dd7d330dd7fc103836409bdcba826d15d88119c7f843357266b253aede72dfb"
|
||||
expect := "b16384a950ed01ed5fc15c03fe7b98228871cb43b1bc22d67029449fc854d104"
|
||||
assert.Equal(t, expect, UtilityTokenID().StringLE())
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,6 @@ func TestGoverningTokenTX(t *testing.T) {
|
|||
//TODO: After we added Nonce field to transaction.Transaction, GoveringTockenTx hash
|
||||
// has been changed. Update it for better times.
|
||||
// Old hash is "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"
|
||||
expect := "0589624521f631b389197e1a69b1b92db0a45cc70f45c3409dfecc439e99bfa9"
|
||||
expect := "7a37715546c6cfa5bac8d7f7e87c667a1e5a6ba0601238be475ab8c79a5abcf5"
|
||||
assert.Equal(t, expect, GoverningTokenID().StringLE())
|
||||
}
|
||||
|
|
|
@ -118,6 +118,12 @@ func (c *Client) TransferNEP5(acc *wallet.Account, to util.Uint160, token *walle
|
|||
return util.Uint256{}, fmt.Errorf("can't calculate validUntilBlock: %v", err)
|
||||
}
|
||||
|
||||
addr, err := address.StringToUint160(acc.Address)
|
||||
if err != nil {
|
||||
return util.Uint256{}, fmt.Errorf("failed to get address: %v", err)
|
||||
}
|
||||
tx.Sender = addr
|
||||
|
||||
if err := request.AddInputsAndUnspentsToTx(tx, acc.Address, core.UtilityTokenID(), gas, c); err != nil {
|
||||
return util.Uint256{}, fmt.Errorf("can't add GAS to transaction: %v", err)
|
||||
}
|
||||
|
|
|
@ -517,18 +517,18 @@ func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sys
|
|||
}
|
||||
tx.ValidUntilBlock = validUntilBlock
|
||||
|
||||
addr, err := address.StringToUint160(acc.Address)
|
||||
if err != nil {
|
||||
return txHash, errors.Wrap(err, "failed to get address")
|
||||
}
|
||||
tx.Sender = addr
|
||||
|
||||
gas := sysfee + netfee
|
||||
|
||||
if gas > 0 {
|
||||
if err = request.AddInputsAndUnspentsToTx(tx, acc.Address, core.UtilityTokenID(), gas, c); err != nil {
|
||||
return txHash, errors.Wrap(err, "failed to add inputs and unspents to transaction")
|
||||
}
|
||||
} else {
|
||||
addr, err := address.StringToUint160(acc.Address)
|
||||
if err != nil {
|
||||
return txHash, errors.Wrap(err, "failed to get address")
|
||||
}
|
||||
tx.AddVerificationHash(addr)
|
||||
}
|
||||
|
||||
if err = acc.SignTx(tx); err != nil {
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
@ -39,7 +39,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetAccountState("")
|
||||
},
|
||||
serverResponse: `{"jsonrpc":"2.0","id": 1,"result":{"version":0,"script_hash":"0x1179716da2e9523d153a35fb3ad10c561b1e5b1a","frozen":false,"votes":[],"balances":[{"asset":"0x0589624521f631b389197e1a69b1b92db0a45cc70f45c3409dfecc439e99bfa9","value":"94"}]}}`,
|
||||
serverResponse: `{"jsonrpc":"2.0","id": 1,"result":{"version":0,"script_hash":"0x1179716da2e9523d153a35fb3ad10c561b1e5b1a","frozen":false,"votes":[],"balances":[{"asset":"0x7a37715546c6cfa5bac8d7f7e87c667a1e5a6ba0601238be475ab8c79a5abcf5","value":"94"}]}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
scriptHash, err := util.Uint160DecodeStringLE("1179716da2e9523d153a35fb3ad10c561b1e5b1a")
|
||||
if err != nil {
|
||||
|
@ -98,7 +98,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetAssetState(util.Uint256{})
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":"0x0589624521f631b389197e1a69b1b92db0a45cc70f45c3409dfecc439e99bfa9","type":0,"name":"NEO","amount":"100000000","available":"100000000","precision":0,"owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":4000000,"is_frozen":false}}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"id":"0x7a37715546c6cfa5bac8d7f7e87c667a1e5a6ba0601238be475ab8c79a5abcf5","type":0,"name":"NEO","amount":"100000000","available":"100000000","precision":0,"owner":"00","admin":"Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt","issuer":"AFmseVrdL9f9oyCzZefL9tG6UbvhPbdYzM","expiration":4000000,"is_frozen":false}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
return &result.AssetState{
|
||||
ID: core.GoverningTokenID(),
|
||||
|
@ -138,17 +138,17 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetBlockByIndex(5)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"00000000a78c4548ad5fd899f4980cffcc8610f4dc22037de3f1fd374cc4384e1eb24e85f0bd34849ad1bda48acd6b9c9401654f9e6499f95dab85923de66c3b1242d59c858e955e050000005704000000000000be48d3a3f5d10013ab9ffee489706078714f1ea201fd040140445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda18b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae010000d50400000500000000000000"}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"00000000b3aa04926a237abc2e54808fb10b5ca2394ae5ccfff17d60c1e393cfd418ed8f265f271088384b2f696e34bea0c8e02cf226351800c0866c1586be521536e579997c9d5e050000005704000000000000be48d3a3f5d10013ab9ffee489706078714f1ea201fd040140a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a0808b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae010000d5040000be48d3a3f5d10013ab9ffee489706078714f1ea20500000000000001fd040140f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd8b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}`,
|
||||
result: func(c *Client) interface{} { return &block.Block{} },
|
||||
check: func(t *testing.T, c *Client, result interface{}) {
|
||||
res, ok := result.(*block.Block)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, uint32(0), res.Version)
|
||||
assert.Equal(t, "a928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9", res.Hash().StringLE())
|
||||
assert.Equal(t, "854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7", res.PrevHash.StringLE())
|
||||
assert.Equal(t, "9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0", res.MerkleRoot.StringLE())
|
||||
assert.Equal(t, "66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906", res.Hash().StringLE())
|
||||
assert.Equal(t, "8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3", res.PrevHash.StringLE())
|
||||
assert.Equal(t, "79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26", res.MerkleRoot.StringLE())
|
||||
assert.Equal(t, 1, len(res.Transactions))
|
||||
assert.Equal(t, "9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0", res.Transactions[0].Hash().StringLE())
|
||||
assert.Equal(t, "79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26", res.Transactions[0].Hash().StringLE())
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -156,25 +156,25 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
invoke: func(c *Client) (i interface{}, err error) {
|
||||
return c.GetBlockByIndexVerbose(5)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hash":"0xa928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9","size":523,"version":0,"nextblockhash":"0x5ff4068d996cbefb6fb6e36f6c8085a79f7ab28cc3149b6f49a55cf97fa4b513","previousblockhash":"0x854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7","merkleroot":"0x9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0","time":1586859653,"index":5,"nonce":"0000000000000457","nextconsensus":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","confirmations":203,"script":{"invocation":"40445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda1","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"sys_fee":"0","net_fee":"0","txid":"0x9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0","size":14,"type":"MinerTransaction","version":0,"nonce":1237,"valid_until_block":5,"attributes":[],"vin":[],"vout":[],"scripts":[]}]}}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hash":"0x66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906","size":946,"version":0,"nextblockhash":"0xf6749a5eb21273ec67951afd22282f002e605e210678c2fa765dbecf0124bd1a","previousblockhash":"0x8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3","merkleroot":"0x79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26","time":1587379353,"index":5,"nonce":"0000000000000457","nextconsensus":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","confirmations":203,"script":{"invocation":"40a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a080","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"sys_fee":"0","net_fee":"0","txid":"0x79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26","size":437,"type":"MinerTransaction","version":0,"nonce":1237,"sender":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","valid_until_block":5,"attributes":[],"vin":[],"vout":[],"scripts":[{"invocation":"40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}]}]}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
hash, err := util.Uint256DecodeStringLE("a928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9")
|
||||
hash, err := util.Uint256DecodeStringLE("66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
nextBlockHash, err := util.Uint256DecodeStringLE("5ff4068d996cbefb6fb6e36f6c8085a79f7ab28cc3149b6f49a55cf97fa4b513")
|
||||
nextBlockHash, err := util.Uint256DecodeStringLE("f6749a5eb21273ec67951afd22282f002e605e210678c2fa765dbecf0124bd1a")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
prevBlockHash, err := util.Uint256DecodeStringLE("854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7")
|
||||
prevBlockHash, err := util.Uint256DecodeStringLE("8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
merkleRoot, err := util.Uint256DecodeStringLE("9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0")
|
||||
merkleRoot, err := util.Uint256DecodeStringLE("79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
invScript, err := hex.DecodeString("40445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda1")
|
||||
invScript, err := hex.DecodeString("40a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a080")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -182,18 +182,37 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sender, err := address.StringToUint160("AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
txInvScript, err := hex.DecodeString("40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
txVerifScript, err := hex.DecodeString("532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tx := transaction.NewMinerTXWithNonce(1237)
|
||||
tx.ValidUntilBlock = 5
|
||||
tx.Sender = sender
|
||||
tx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: txInvScript,
|
||||
VerificationScript: txVerifScript,
|
||||
},
|
||||
}
|
||||
// Update hashes for correct result comparison.
|
||||
_ = tx.Hash()
|
||||
return &result.Block{
|
||||
Hash: hash,
|
||||
Size: 523,
|
||||
Size: 946,
|
||||
Version: 0,
|
||||
NextBlockHash: &nextBlockHash,
|
||||
PreviousBlockHash: prevBlockHash,
|
||||
MerkleRoot: merkleRoot,
|
||||
Time: 1586859653,
|
||||
Time: 1587379353,
|
||||
Index: 5,
|
||||
Nonce: "0000000000000457",
|
||||
NextConsensus: "AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU",
|
||||
|
@ -215,53 +234,53 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
{
|
||||
name: "byHash_positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
hash, err := util.Uint256DecodeStringLE("f97aa7a97ce4e778a09b80b476e39d0c86b2ef14fa882bb0ebc8bb94e3e628a9")
|
||||
hash, err := util.Uint256DecodeStringLE("0699071a3d86ab915156da98db49a4c3eb34509c6a9ae647aa0edcfb40c1d166")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c.GetBlockByHash(hash)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"00000000a78c4548ad5fd899f4980cffcc8610f4dc22037de3f1fd374cc4384e1eb24e85f0bd34849ad1bda48acd6b9c9401654f9e6499f95dab85923de66c3b1242d59c858e955e050000005704000000000000be48d3a3f5d10013ab9ffee489706078714f1ea201fd040140445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda18b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae010000d50400000500000000000000"}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"00000000b3aa04926a237abc2e54808fb10b5ca2394ae5ccfff17d60c1e393cfd418ed8f265f271088384b2f696e34bea0c8e02cf226351800c0866c1586be521536e579997c9d5e050000005704000000000000be48d3a3f5d10013ab9ffee489706078714f1ea201fd040140a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a0808b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae010000d5040000be48d3a3f5d10013ab9ffee489706078714f1ea20500000000000001fd040140f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd8b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}`,
|
||||
result: func(c *Client) interface{} { return &block.Block{} },
|
||||
check: func(t *testing.T, c *Client, result interface{}) {
|
||||
res, ok := result.(*block.Block)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, uint32(0), res.Version)
|
||||
assert.Equal(t, "a928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9", res.Hash().StringLE())
|
||||
assert.Equal(t, "854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7", res.PrevHash.StringLE())
|
||||
assert.Equal(t, "9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0", res.MerkleRoot.StringLE())
|
||||
assert.Equal(t, "66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906", res.Hash().StringLE())
|
||||
assert.Equal(t, "8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3", res.PrevHash.StringLE())
|
||||
assert.Equal(t, "79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26", res.MerkleRoot.StringLE())
|
||||
assert.Equal(t, 1, len(res.Transactions))
|
||||
assert.Equal(t, "9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0", res.Transactions[0].Hash().StringLE())
|
||||
assert.Equal(t, "79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26", res.Transactions[0].Hash().StringLE())
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "byHash_verbose_positive",
|
||||
invoke: func(c *Client) (i interface{}, err error) {
|
||||
hash, err := util.Uint256DecodeStringLE("f97aa7a97ce4e778a09b80b476e39d0c86b2ef14fa882bb0ebc8bb94e3e628a9")
|
||||
hash, err := util.Uint256DecodeStringLE("0699071a3d86ab915156da98db49a4c3eb34509c6a9ae647aa0edcfb40c1d166")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c.GetBlockByHashVerbose(hash)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hash":"0xa928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9","size":523,"version":0,"nextblockhash":"0x5ff4068d996cbefb6fb6e36f6c8085a79f7ab28cc3149b6f49a55cf97fa4b513","previousblockhash":"0x854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7","merkleroot":"0x9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0","time":1586859653,"index":5,"nonce":"0000000000000457","nextconsensus":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","confirmations":203,"script":{"invocation":"40445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda1","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"sys_fee":"0","net_fee":"0","txid":"0x9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0","size":14,"type":"MinerTransaction","version":0,"nonce":1237,"valid_until_block":5,"attributes":[],"vin":[],"vout":[],"scripts":[]}]}}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"hash":"0x66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906","size":946,"version":0,"nextblockhash":"0xf6749a5eb21273ec67951afd22282f002e605e210678c2fa765dbecf0124bd1a","previousblockhash":"0x8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3","merkleroot":"0x79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26","time":1587379353,"index":5,"nonce":"0000000000000457","nextconsensus":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","confirmations":203,"script":{"invocation":"40a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a080","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"},"tx":[{"sys_fee":"0","net_fee":"0","txid":"0x79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26","size":437,"type":"MinerTransaction","version":0,"nonce":1237,"sender":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","valid_until_block":5,"attributes":[],"vin":[],"vout":[],"scripts":[{"invocation":"40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}]}]}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
hash, err := util.Uint256DecodeStringLE("a928e6e394bbc8ebb02b88fa14efb2860c9de376b4809ba078e7e47ca9a77af9")
|
||||
hash, err := util.Uint256DecodeStringLE("66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
nextBlockHash, err := util.Uint256DecodeStringLE("5ff4068d996cbefb6fb6e36f6c8085a79f7ab28cc3149b6f49a55cf97fa4b513")
|
||||
nextBlockHash, err := util.Uint256DecodeStringLE("f6749a5eb21273ec67951afd22282f002e605e210678c2fa765dbecf0124bd1a")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
prevBlockHash, err := util.Uint256DecodeStringLE("854eb21e4e38c44c37fdf1e37d0322dcf41086ccff0c98f499d85fad48458ca7")
|
||||
prevBlockHash, err := util.Uint256DecodeStringLE("8fed18d4cf93e3c1607df1ffcce54a39a25c0bb18f80542ebc7a236a9204aab3")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
merkleRoot, err := util.Uint256DecodeStringLE("9cd542123b6ce63d9285ab5df999649e4f6501949c6bcd8aa4bdd19a8434bdf0")
|
||||
merkleRoot, err := util.Uint256DecodeStringLE("79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
invScript, err := hex.DecodeString("40445e8de1ba402cab0bffedc32840b3587c8f6b272c02ea2b4a609419fbcb85a3cf5cd183ea7d28788eb19a12265be1d2f43f7986de66c8d8585d66825a0701fc40d935dfb83310d3433a7afc0bbb15f4c0686a624734cee6f6b98d5d95e660401c5b35c7cfd802fa82759aab288373ad894d82056d29109e6142d8c1397f60706f4076e9fd7bef3b9a8ce12904414cc55293161bcb536a4939200dd3c586c4d60ded565780d307598b8dcf4eebb64f53cc9fc0c381d47e58b7cec1b9392097a2b3ec407b03a25d83d429810b7a929f48b8125d3bfff5982f876c0dbd1d9dbbf08534d3235a4709c7f779449ed865ca1d2e29729c0210174782869a09c2b821bd15fda1")
|
||||
invScript, err := hex.DecodeString("40a6cc2c7fdee4f8fd97f84114d04edda16a37a4c088da9d5be3233e118fccdf73c0305d2cbd15ea0dbcedb594fec3044844e8f59f236ded7fccb1eda2eee2c76740197eba5d648d650ca1d73b8c0a0c7cdc22d31d7b2564764729d271e7ff6378c4f2228f657d65fec530f2af6cdc7af3bc2ab17a7b8175376601fb17ec951faf074038222bb0430f7808d333be3fb8e5b93c490dbb07e6c085350ba64cb7de61127067d1825de30915964dbb345f3b902d61dbf9a294c11ff6459000648f0dc4e66740926854a25b9ea87d7fffe0253bf2bcb3d153434cc0a8ba166136d16aef9a3de70ba3704ba3103a26d01c2bdbeb7262a19bbceab6a7487beba5e55f7ee768a080")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -269,18 +288,37 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sender, err := address.StringToUint160("AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
txInvScript, err := hex.DecodeString("40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
txVerifScript, err := hex.DecodeString("532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tx := transaction.NewMinerTXWithNonce(1237)
|
||||
tx.ValidUntilBlock = 5
|
||||
tx.Sender = sender
|
||||
tx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: txInvScript,
|
||||
VerificationScript: txVerifScript,
|
||||
},
|
||||
}
|
||||
// Update hashes for correct result comparison.
|
||||
_ = tx.Hash()
|
||||
return &result.Block{
|
||||
Hash: hash,
|
||||
Size: 523,
|
||||
Size: 946,
|
||||
Version: 0,
|
||||
NextBlockHash: &nextBlockHash,
|
||||
PreviousBlockHash: prevBlockHash,
|
||||
MerkleRoot: merkleRoot,
|
||||
Time: 1586859653,
|
||||
Time: 1587379353,
|
||||
Index: 5,
|
||||
Nonce: "0000000000000457",
|
||||
NextConsensus: "AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU",
|
||||
|
@ -610,19 +648,19 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
invoke: func(c *Client) (i interface{}, err error) {
|
||||
hash, err := util.Uint256DecodeStringLE("0b698b4ac68fc3206e65868e8f51ea5ac29e92b5faf9e79562cd57fc744d47c5")
|
||||
hash, err := util.Uint256DecodeStringLE("265f271088384b2f696e34bea0c8e02cf226351800c0866c1586be521536e579")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c.GetRawTransaction(hash)
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"00001dac2b7c0100000000000000"}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":"0000d5040000be48d3a3f5d10013ab9ffee489706078714f1ea20500000000000001fd040140f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd8b532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}`,
|
||||
result: func(c *Client) interface{} { return &transaction.Transaction{} },
|
||||
check: func(t *testing.T, c *Client, result interface{}) {
|
||||
res, ok := result.(*transaction.Transaction)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, uint8(0), res.Version)
|
||||
assert.Equal(t, "0b698b4ac68fc3206e65868e8f51ea5ac29e92b5faf9e79562cd57fc744d47c5", res.Hash().StringBE())
|
||||
assert.Equal(t, "265f271088384b2f696e34bea0c8e02cf226351800c0866c1586be521536e579", res.Hash().StringBE())
|
||||
assert.Equal(t, transaction.MinerType, res.Type)
|
||||
assert.Equal(t, false, res.Trimmed)
|
||||
},
|
||||
|
@ -630,20 +668,39 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
{
|
||||
name: "verbose_positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
hash, err := util.Uint256DecodeStringLE("0b698b4ac68fc3206e65868e8f51ea5ac29e92b5faf9e79562cd57fc744d47c5")
|
||||
hash, err := util.Uint256DecodeStringLE("265f271088384b2f696e34bea0c8e02cf226351800c0866c1586be521536e579")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c.GetRawTransactionVerbose(hash)
|
||||
},
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sys_fee":"0","net_fee":"0","blockhash":"0x77007ec4921dd78e91c26bee9c14b49148ae08140f698accea49ecc279e68435","confirmations":210,"blocktime":1468595301,"txid":"0xc5474d74fc57cd6295e7f9fab5929ec25aea518f8e86656e20c38fc64a8b690b","size":14,"type":"MinerTransaction","version":0,"nonce":2083236893,"valid_until_block":1,"attributes":[],"vin":[],"vout":[],"scripts":[]}}`,
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"sys_fee":"0","net_fee":"0","blockhash":"0x66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906","confirmations":205,"blocktime":1587379353,"txid":"0x79e5361552be86156c86c000183526f22ce0c8a0be346e692f4b388810275f26","size":437,"type":"MinerTransaction","version":0,"nonce":1237,"sender":"AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU","valid_until_block":5,"attributes":[],"vin":[],"vout":[],"scripts":[{"invocation":"40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd","verification":"532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae"}]}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
blockHash, err := util.Uint256DecodeStringLE("77007ec4921dd78e91c26bee9c14b49148ae08140f698accea49ecc279e68435")
|
||||
blockHash, err := util.Uint256DecodeStringLE("66d1c140fbdc0eaa47e69a6a9c5034ebc3a449db98da565191ab863d1a079906")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tx := transaction.NewMinerTXWithNonce(2083236893)
|
||||
tx.ValidUntilBlock = 1
|
||||
sender, err := address.StringToUint160("AZ81H31DMWzbSnFDLFkzh9vHwaDLayV7fU")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
invocation, err := hex.DecodeString("40f50121bb6ec9d8e0d1c15eea66b2ff7b51bb1bc4b3da27d9eac1d46b59e6a319bb1db4eb710c7f1931b0c2deaa2389a0fc3fe8c761cec40906b7973450c43173402dc082417a6815e722216de0b857eda6c846bf435088d543d2ab89f1dd92488e87b4d2c6508b0db945cbe6968e85c1c6d57274bfc898e82876c5cb08613da5d64053100f0162a41709a37305c300e7d6ac0d46575aab98dade7375b8d9ca980086594f1288dc68da0e0e42913d1c68024f63442a79c9478971d3ad93c5467ec53040a1c3a772a88b09cba8cc8ec3b46c0c0db6ac86519a7fd7db29b43d34e804a22d8839eaeb35e2a1e05d591fbad4ae290b90c6dc02dddbe28b2b3bf0fec2a337dd")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
verification, err := hex.DecodeString("532102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd622102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc22103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee69954ae")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tx := transaction.NewMinerTXWithNonce(1237)
|
||||
tx.ValidUntilBlock = 5
|
||||
tx.Sender = sender
|
||||
tx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: invocation,
|
||||
VerificationScript: verification,
|
||||
},
|
||||
}
|
||||
// Update hashes for correct result comparison.
|
||||
_ = tx.Hash()
|
||||
|
||||
|
@ -653,8 +710,8 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
SysFee: 0,
|
||||
NetFee: 0,
|
||||
Blockhash: blockHash,
|
||||
Confirmations: 210,
|
||||
Timestamp: uint32(1468595301),
|
||||
Confirmations: 205,
|
||||
Timestamp: uint32(1587379353),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
|
@ -38,7 +38,7 @@ func CreateRawContractTransaction(params ContractTxParams) (*transaction.Transac
|
|||
if toAddressHash, err = address.StringToUint160(toAddress); err != nil {
|
||||
return nil, errs.Wrapf(err, "Failed to take script hash from address: %v", toAddress)
|
||||
}
|
||||
tx.AddVerificationHash(fromAddressHash)
|
||||
tx.Sender = fromAddressHash
|
||||
|
||||
if err = AddInputsAndUnspentsToTx(tx, fromAddress, assetID, amount, balancer); err != nil {
|
||||
return nil, errs.Wrap(err, "failed to add inputs and unspents to transaction")
|
||||
|
|
|
@ -49,14 +49,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getapplicationlog": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["a62dccca145b9df9793ddbe80fd96fd6360403c52926909b9e6fd9a4ac5549aa"]`,
|
||||
params: `["af51984d1dbec1557c9c14d8d404ff35015e53255d53e8c7f55088a74ecc399b"]`,
|
||||
result: func(e *executor) interface{} { return &result.ApplicationLog{} },
|
||||
check: func(t *testing.T, e *executor, acc interface{}) {
|
||||
res, ok := acc.(*result.ApplicationLog)
|
||||
|
||||
require.True(t, ok)
|
||||
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("a62dccca145b9df9793ddbe80fd96fd6360403c52926909b9e6fd9a4ac5549aa")
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("af51984d1dbec1557c9c14d8d404ff35015e53255d53e8c7f55088a74ecc399b")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||
assert.Equal(t, 1, len(res.Executions))
|
||||
|
@ -251,7 +249,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getassetstate": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["8dd7d330dd7fc103836409bdcba826d15d88119c7f843357266b253aede72dfb"]`,
|
||||
params: `["b16384a950ed01ed5fc15c03fe7b98228871cb43b1bc22d67029449fc854d104"]`,
|
||||
result: func(e *executor) interface{} { return &result.AssetState{} },
|
||||
check: func(t *testing.T, e *executor, as interface{}) {
|
||||
res, ok := as.(*result.AssetState)
|
||||
|
@ -405,25 +403,25 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getblockheader": {
|
||||
{
|
||||
name: "positive, no verbose",
|
||||
params: `["26d52a2541614f8639bc030493c4f2be2003094bbba2219aee3e097beb730a8d"]`,
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
expected := "000000002f1f4e815a5951622f4c3863d5a27da7819259517971118de2f979d70850c15d4c8edb530dbd32f20674901fea73dd41c6b1af2ab9520b92447460351727be2c28a3995e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140e87e9ea015e46febb3ef938d7a458b2f70d84eb0584b2b22b0f85ecfe292d98742569d27ef2f4eafca967a9bbbb1e90efe4046d550f821f70fe39cb07aa70b87409d894b16bc8ab1b1edb0e921e0171ea7e8bf713854896eddd9d1bbc8e2ec80df616e30c0518dd3053a8d53464bb5615bd2cc83aca8fb9a8c37a259a30ba9a571405cfbfee1b86d4819c25f6a97374cef09733fc006e73ee18e5ada58d348983e1b753fad166c7220154fe21ca482feccaf1ff1598660ab7bef087ca16325db4ed9403baed63512e0bec4d5afb8c27525951a8855e579530c9ebf5aae4430492a426abb2eac309828c83e1d132bf9334b31d538fde4a2cfdb9e50da16b29db787152c94534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
expected := "000000003a879986b02b0f46b6a311b74799446f1fca447c1a4ae7baa804876194669cfd14aa46a5e3e62056c842d54ea5ba480fc448c498989f505bcae9ae4364436b9dd78b9d5e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140fd33aaf63b15fcfb1d2ad465297e35e52e26d9049c28022fd8f4a27fca573135e539852f5093d37fc3ebb669b3ad7998c250ae7b7d073ba29aa59738f5543d844003422200411a06e5ddb5d148cd16314d9f5a66ed6d91efd6abf8d8f9757487e1066016e3c333842b90509eb05fa33f2d7adf7c270d892839f68a62b037ce1ae040452ea91701a973650958337caa1e646b06dfa63d1e6357e0bbfb9ad4cb0a74e4c2fbac23f980675c26167b720717fa95552c1f795becac1f7c1ea2be20571a9a4012125e56f2d562980b833ecc9d5e8dc12b253a591a06059a8ccf1c1850b32220c310d9376b627b3c8975f88d78ff3b08d332c8d63210f8ae9c68d87181148fc894534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
return &expected
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "positive, verbose 0",
|
||||
params: `["26d52a2541614f8639bc030493c4f2be2003094bbba2219aee3e097beb730a8d", 0]`,
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958", 0]`,
|
||||
result: func(e *executor) interface{} {
|
||||
expected := "000000002f1f4e815a5951622f4c3863d5a27da7819259517971118de2f979d70850c15d4c8edb530dbd32f20674901fea73dd41c6b1af2ab9520b92447460351727be2c28a3995e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140e87e9ea015e46febb3ef938d7a458b2f70d84eb0584b2b22b0f85ecfe292d98742569d27ef2f4eafca967a9bbbb1e90efe4046d550f821f70fe39cb07aa70b87409d894b16bc8ab1b1edb0e921e0171ea7e8bf713854896eddd9d1bbc8e2ec80df616e30c0518dd3053a8d53464bb5615bd2cc83aca8fb9a8c37a259a30ba9a571405cfbfee1b86d4819c25f6a97374cef09733fc006e73ee18e5ada58d348983e1b753fad166c7220154fe21ca482feccaf1ff1598660ab7bef087ca16325db4ed9403baed63512e0bec4d5afb8c27525951a8855e579530c9ebf5aae4430492a426abb2eac309828c83e1d132bf9334b31d538fde4a2cfdb9e50da16b29db787152c94534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
expected := "000000003a879986b02b0f46b6a311b74799446f1fca447c1a4ae7baa804876194669cfd14aa46a5e3e62056c842d54ea5ba480fc448c498989f505bcae9ae4364436b9dd78b9d5e010000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140fd33aaf63b15fcfb1d2ad465297e35e52e26d9049c28022fd8f4a27fca573135e539852f5093d37fc3ebb669b3ad7998c250ae7b7d073ba29aa59738f5543d844003422200411a06e5ddb5d148cd16314d9f5a66ed6d91efd6abf8d8f9757487e1066016e3c333842b90509eb05fa33f2d7adf7c270d892839f68a62b037ce1ae040452ea91701a973650958337caa1e646b06dfa63d1e6357e0bbfb9ad4cb0a74e4c2fbac23f980675c26167b720717fa95552c1f795becac1f7c1ea2be20571a9a4012125e56f2d562980b833ecc9d5e8dc12b253a591a06059a8ccf1c1850b32220c310d9376b627b3c8975f88d78ff3b08d332c8d63210f8ae9c68d87181148fc894534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"
|
||||
return &expected
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "positive, verbose !=0",
|
||||
params: `["26d52a2541614f8639bc030493c4f2be2003094bbba2219aee3e097beb730a8d", 2]`,
|
||||
params: `["ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958", 2]`,
|
||||
result: func(e *executor) interface{} {
|
||||
hash, err := util.Uint256DecodeStringLE("26d52a2541614f8639bc030493c4f2be2003094bbba2219aee3e097beb730a8d")
|
||||
hash, err := util.Uint256DecodeStringLE("ad185bb609f95fd709b6a9cce9f67ee636c4acdac9afcafb26209d922a889958")
|
||||
if err != nil {
|
||||
panic("can not decode hash parameter")
|
||||
}
|
||||
|
@ -520,7 +518,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
params: `["AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6"]`,
|
||||
result: func(*executor) interface{} {
|
||||
// hash of the issueTx
|
||||
h, _ := util.Uint256DecodeStringBE("e9a7882fa874508dff8a3f21d32da2afb9f9d303753953a524c75b81e295c914")
|
||||
h, _ := util.Uint256DecodeStringBE("4cccf8f1a4cfa9ebd9344c312f8220199ee9000f14cb951f677601d208aa5af0")
|
||||
amount := util.Fixed8FromInt64(1 * 8) // (endHeight - startHeight) * genAmount[0]
|
||||
return &result.ClaimableInfo{
|
||||
Spents: []result.Claimable{
|
||||
|
@ -578,8 +576,8 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
},
|
||||
"gettransactionheight": {
|
||||
{
|
||||
name: "poositive",
|
||||
params: `["4b0be2562c7f49a496f08eb6983b46904c99dfb7c65d3a32d7b09cbc503a7889"]`,
|
||||
name: "positive",
|
||||
params: `["865469df8fab5f665b37c67de3beba832fa17b27675d4ac2eec0d60ce40f42fd"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
h := 1
|
||||
return &h
|
||||
|
@ -791,7 +789,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"sendrawtransaction": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["800013000000b004000000013bc3087e4af3b30310500396aa972d7a8ac87a7046dff9dc030e03c2bbc09be9010001a9bf999e43ccfe9d40c3450fc75ca4b02db9b1691a7e1989b331f621456289050030d3dec38623006501dbe71845f26f6b4d848b034d624eeda7bbc40141401026a8d3bd5839d1ead869dcba75dd19c112671d5a86e3443e4fd8c456e8c3fae1ed108065bfe47d62127e33a2419ee1d2140a66712c6ae4b5d2ad0758c5b5dd294c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4"]`,
|
||||
params: `["8000130000006501dbe71845f26f6b4d848b034d624eeda7bbc4b00400000001d41146fbea5a066daa8ff358822fba2b5a60d0b554feccb5ee54cedbdb86315c010001f5bc5a9ac7b85a47be381260a06b5a1e7a667ce8f7d7c8baa5cfc6465571377a0030d3dec38623006501dbe71845f26f6b4d848b034d624eeda7bbc40141402ddc9a3b036932fa42df8e97f7fe713e2c673060d1d4134ce93e35da790b98bd744beb7a37d515371929f98ee2642699303856ea603d1d68fc157174aa586671294c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
@ -822,7 +820,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
// If you are planning to modify test chain from `testblocks.acc`, please, update param value (first block)
|
||||
name: "empty block",
|
||||
params: `["00000000f0fae05006c8c784404415faf69023f9e607f04a1fcfde2a4bd93a8c3fdfd1980000000000000000000000000000000000000000000000000000000000000000f8a3995ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140a3f627a07ae219f3dce5525f1b01b913c7dbe9ba6a725bdf49733290e5f3e50f2ba8f434d564ebfaeae40433a4b8746dccb2d4ab36712a87d3600e07548f398140b2e23d220f965736277f509e659f76c8bc376b1b28c3d4c817fbd96ec82eb4e11a5c4fe67b7df6ff8f6efe2a71c3582a7c0403494f84f90c4efc7a314b2c6c8d404f5dcd7ac82e541e7fda965460df0a8563f0ca71c7211263f9dc783a77a6b968bc1f7bf57f34fe48f8978aa94d6c21bcde59bc6dae16eee0d37ec5d8bb0447d240dc6dd5692f1a49862805e18f2a77016ee94e3529cb2856571b9146e53f572fed1c6e31e655b8f94e55a665c25001d3477375db31d6924e88d32ded33a6d6f6cb94534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"]`,
|
||||
params: `["00000000bdd51295d6e8bbfcff7d08ddfc2e8d6b509829547f8f834a259d785f88c5dd030000000000000000000000000000000000000000000000000000000000000000a78c9d5ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd04014064132b8f90426ebc0370693a16a0bf9a334b3022fe1b0e7abbdded639892cd8ce5a222de32c90e6882b155d21da95e8b7dda4c9e2641fb605b1ea04d3b8de056405456777ba6296fe98f0c9af9364a84691f5b3c3f7a6f19ca600d02db6ba2ab019ef6cb67c0c39ee6b6c98a9e920eec592e73ac8525949fada9094368adcaa06140eb3b961953d97daedb0898da8a7d32f0a3de0eb553ef55c5ae6fe982d9442804be1b883e2d9ebcff592c4c57350acb1527a669e6bf15d560295701ed71dbaa5a4018d2accab62726b7608c8370c601f5916b5ff87e3552f1c17a06b8453037a7a20a4c3c937e002c5dbbfc1f877a9e08b401d688fca96de4aba79e92a2f7e90f9594534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb00"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
|
@ -848,7 +846,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
// If you are planning to modify test chain from `testblocks.acc`, please, update param value (second block)
|
||||
params: `["00000000f0fae05006c8c784404415faf69023f9e607f04a1fcfde2a4bd93a8c3fdfd198980135e10c52e5444c962659b388a5b226114a45d3912a88700ac6b05aaaf961f8a3995ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd0401406413cf294f0506e81b73a8b6f9ecc8d1ac73afc55852ca65ff2dc08ee217425030d8b16ec36d7f7b1111198337185f71ac2b24b9e4ca8806bc2c3ba5f63bf31540f48633e1541acdbdb4509e522b49e4df48b55bc884f5fd5abae014292f74ca7066232967176826fbb0b6919e14b3c9e91b916cb7003c019b8afb42e37cf97e9140d8f44efe93ab380bab8b6fc29e5d8ba1502feda12eb35c9472906e5c46ffdfff56047f383aa87b9724c219eca43d165c31fb246528e410fbcb4a9a04816c77aa40187874fb7193ce5613382e0059f0ff421fc252c31c83e299dfd097a453afb8a65fd95c7711d4d247ad82179e98146338b58864caf8601a6bb7b62300fa9af9e594534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb01000014000000b004000000000000"]`,
|
||||
params: `["00000000bdd51295d6e8bbfcff7d08ddfc2e8d6b509829547f8f834a259d785f88c5dd036801125aaa2b6bdaa47414006f28316315df928520e630a702e944522720ad06a78c9d5ed10000005704000000000000d60ac443bb800fb08261e75fa5925d747d48586101fd040140caf89bf82fd25e9b3d0d0fab62fbf832df753116682e23939441da868a79c5d8cf4000066130de95d184a778053a3c41cf832009add80ecb7648621de5ad63ef4060438f3f3a7744a813c9d1ebd814a2ca5d55ea86f223a56dd7f295d9d3f355687e679311656e83c014642f78e22a9c8388d880e64080e1f07de420b280e0023a4053478c1eaac15771a07506bc97d0b6f1766b8cb0d5f98ead7e5df30555ec1bb409c7e57d4e8286beeb23221a2e01273240ad74ab7ee88474812848392fdc9f8e401391d88d7a0add6d79fa9f3c5598707fc89bcb372b3e40a76d90b57f0e615c503b10b2c648df2b79f22ca949f143aaeae3a6bd4b64f666965fbc1c286c0a6dcb94534c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e4c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd624c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc24c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee6995450683073b3bb010000140000006501dbe71845f26f6b4d848b034d624eeda7bbc4b0040000000000014140acddd18b655f8692dd169c7dcf53923dc85cbe34852cf4220dffdfea284dbca19035dff2f8655245d51a4823719fef1228e40351213633c9b46aed79df2eaa4e294c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc250680a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
@ -921,7 +919,7 @@ func TestRPC(t *testing.T) {
|
|||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "4000000000000000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000", res)
|
||||
assert.Equal(t, "400000000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b0000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000", res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments", func(t *testing.T) {
|
||||
|
@ -933,7 +931,7 @@ func TestRPC(t *testing.T) {
|
|||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "4000000000000000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000", res)
|
||||
assert.Equal(t, "400000000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b0000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000", res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments, verbose", func(t *testing.T) {
|
||||
|
@ -973,7 +971,7 @@ func TestRPC(t *testing.T) {
|
|||
err := json.Unmarshal(res, &txOut)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", res)
|
||||
assert.Equal(t, 0, txOut.N)
|
||||
assert.Equal(t, "0xa9bf999e43ccfe9d40c3450fc75ca4b02db9b1691a7e1989b331f62145628905", txOut.Asset)
|
||||
assert.Equal(t, "0xf5bc5a9ac7b85a47be381260a06b5a1e7a667ce8f7d7c8baa5cfc6465571377a", txOut.Asset)
|
||||
assert.Equal(t, util.Fixed8FromInt64(100000000), txOut.Value)
|
||||
assert.Equal(t, "AbHd9dXYUryuCvMgXRUfdR6zC2CJixS6Q6", txOut.Address)
|
||||
})
|
||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
Loading…
Reference in a new issue