forked from TrueCloudLab/neoneo-go
core: drop UXTO NEO and GAS transactions from the genesis block
They're no longer required. Adjust test chain for that, now it only has invocations, transfers NEO/GAS and pays the fees with NEP5 GAS.
This commit is contained in:
parent
a9955719da
commit
9f5fd21160
5 changed files with 117 additions and 206 deletions
|
@ -165,20 +165,21 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
return testNonce
|
||||
}
|
||||
|
||||
var neoAmount = util.Fixed8FromInt64(99999000)
|
||||
var neoRemainder = util.Fixed8FromInt64(100000000) - neoAmount
|
||||
const neoAmount = 99999000
|
||||
bc := newTestChain(t)
|
||||
defer bc.Close()
|
||||
|
||||
gasHash := bc.contracts.GAS.Hash
|
||||
neoHash := bc.contracts.NEO.Hash
|
||||
t.Logf("native GAS hash: %v", gasHash)
|
||||
t.Logf("native NEO hash: %v", neoHash)
|
||||
|
||||
priv0 := testchain.PrivateKeyByID(0)
|
||||
priv0ScriptHash := priv0.GetScriptHash()
|
||||
|
||||
require.Equal(t, util.Fixed8FromInt64(0), bc.GetUtilityTokenBalance(priv0ScriptHash))
|
||||
// Move almost all NEO and some nep5 GAS to one simple account.
|
||||
txMoveNeo := newNEP5Transfer(gasHash, neoOwner, priv0ScriptHash, int64(util.Fixed8FromInt64(1000)))
|
||||
// Move some NEO to one simple account.
|
||||
txMoveNeo := newNEP5Transfer(neoHash, neoOwner, priv0ScriptHash, neoAmount)
|
||||
txMoveNeo.ValidUntilBlock = validUntilBlock
|
||||
txMoveNeo.Nonce = getNextNonce()
|
||||
txMoveNeo.Sender = neoOwner
|
||||
|
@ -188,32 +189,23 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
AllowedContracts: nil,
|
||||
AllowedGroups: nil,
|
||||
}}
|
||||
|
||||
// use output of issue tx from genesis block as an input
|
||||
genesisBlock, err := bc.GetBlock(bc.GetHeaderHash(0))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 4, len(genesisBlock.Transactions))
|
||||
h := genesisBlock.Transactions[2].Hash()
|
||||
txMoveNeo.AddInput(&transaction.Input{
|
||||
PrevHash: h,
|
||||
PrevIndex: 0,
|
||||
})
|
||||
txMoveNeo.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoAmount,
|
||||
ScriptHash: priv0ScriptHash,
|
||||
Position: 0,
|
||||
})
|
||||
txMoveNeo.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoRemainder,
|
||||
ScriptHash: neoOwner,
|
||||
Position: 1,
|
||||
})
|
||||
require.NoError(t, signTx(bc, txMoveNeo))
|
||||
b := bc.newBlock(txMoveNeo)
|
||||
// Move some GAS to one simple account.
|
||||
txMoveGas := newNEP5Transfer(gasHash, neoOwner, priv0ScriptHash, int64(util.Fixed8FromInt64(1000)))
|
||||
txMoveGas.ValidUntilBlock = validUntilBlock
|
||||
txMoveGas.Nonce = getNextNonce()
|
||||
txMoveGas.Sender = neoOwner
|
||||
txMoveGas.Cosigners = []transaction.Cosigner{{
|
||||
Account: neoOwner,
|
||||
Scopes: transaction.CalledByEntry,
|
||||
AllowedContracts: nil,
|
||||
AllowedGroups: nil,
|
||||
}}
|
||||
require.NoError(t, signTx(bc, txMoveGas))
|
||||
b := bc.newBlock(txMoveNeo, txMoveGas)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txMoveNeo: %s", txMoveNeo.Hash().StringLE())
|
||||
t.Logf("txMoveGas: %s", txMoveGas.Hash().StringLE())
|
||||
|
||||
require.Equal(t, util.Fixed8FromInt64(1000), bc.GetUtilityTokenBalance(priv0ScriptHash))
|
||||
// info for getblockheader rpc tests
|
||||
|
@ -222,60 +214,9 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
b.Header().EncodeBinary(buf.BinWriter)
|
||||
t.Logf("header: %s", hex.EncodeToString(buf.Bytes()))
|
||||
|
||||
// Generate some blocks to be able to claim GAS for them.
|
||||
_, err = bc.genBlocks(numOfEmptyBlocks)
|
||||
require.NoError(t, err)
|
||||
|
||||
acc0, err := wallet.NewAccountFromWIF(priv0.WIF())
|
||||
require.NoError(t, err)
|
||||
|
||||
// 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(),
|
||||
PrevIndex: 0,
|
||||
})
|
||||
txNeoRound.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoAmount,
|
||||
ScriptHash: priv0.GetScriptHash(),
|
||||
Position: 0,
|
||||
})
|
||||
txNeoRound.Data = new(transaction.ContractTX)
|
||||
require.NoError(t, addNetworkFee(bc, txNeoRound, acc0))
|
||||
require.NoError(t, acc0.SignTx(txNeoRound))
|
||||
b = bc.newBlock(txNeoRound)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txNeoRound: %s", txNeoRound.Hash().StringLE())
|
||||
|
||||
claim := new(transaction.ClaimTX)
|
||||
claim.Claims = append(claim.Claims, transaction.Input{
|
||||
PrevHash: txMoveNeo.Hash(),
|
||||
PrevIndex: 0,
|
||||
})
|
||||
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)
|
||||
gasOwned := neoGas + sysGas
|
||||
txClaim.AddOutput(&transaction.Output{
|
||||
AssetID: UtilityTokenID(),
|
||||
Amount: gasOwned,
|
||||
ScriptHash: priv0.GetScriptHash(),
|
||||
Position: 0,
|
||||
})
|
||||
require.NoError(t, addNetworkFee(bc, txClaim, acc0))
|
||||
require.NoError(t, acc0.SignTx(txClaim))
|
||||
b = bc.newBlock(txClaim)
|
||||
require.NoError(t, bc.AddBlock(b))
|
||||
t.Logf("txClaim: %s", txClaim.Hash().StringLE())
|
||||
|
||||
// Push some contract into the chain.
|
||||
avm, err := ioutil.ReadFile(prefix + "test_contract.avm")
|
||||
require.NoError(t, err)
|
||||
|
@ -303,17 +244,6 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txDeploy.Nonce = getNextNonce()
|
||||
txDeploy.ValidUntilBlock = validUntilBlock
|
||||
txDeploy.Sender = priv0ScriptHash
|
||||
txDeploy.AddInput(&transaction.Input{
|
||||
PrevHash: txClaim.Hash(),
|
||||
PrevIndex: 0,
|
||||
})
|
||||
txDeploy.AddOutput(&transaction.Output{
|
||||
AssetID: UtilityTokenID(),
|
||||
Amount: gasOwned - invFee,
|
||||
ScriptHash: priv0.GetScriptHash(),
|
||||
Position: 0,
|
||||
})
|
||||
gasOwned -= invFee
|
||||
require.NoError(t, addNetworkFee(bc, txDeploy, acc0))
|
||||
require.NoError(t, acc0.SignTx(txDeploy))
|
||||
b = bc.newBlock(txDeploy)
|
||||
|
@ -335,26 +265,18 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
t.Logf("txInv: %s", txInv.Hash().StringLE())
|
||||
|
||||
priv1 := testchain.PrivateKeyByID(1)
|
||||
txNeo0to1 := transaction.NewContractTX()
|
||||
txNeo0to1 := newNEP5Transfer(neoHash, priv0ScriptHash, priv1.GetScriptHash(), 1000)
|
||||
txNeo0to1.Nonce = getNextNonce()
|
||||
txNeo0to1.ValidUntilBlock = validUntilBlock
|
||||
txNeo0to1.Sender = priv0ScriptHash
|
||||
txNeo0to1.Data = new(transaction.ContractTX)
|
||||
txNeo0to1.AddInput(&transaction.Input{
|
||||
PrevHash: txNeoRound.Hash(),
|
||||
PrevIndex: 0,
|
||||
})
|
||||
txNeo0to1.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: util.Fixed8FromInt64(1000),
|
||||
ScriptHash: priv1.GetScriptHash(),
|
||||
})
|
||||
txNeo0to1.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoAmount - util.Fixed8FromInt64(1000),
|
||||
ScriptHash: priv0.GetScriptHash(),
|
||||
})
|
||||
|
||||
txNeo0to1.Cosigners = []transaction.Cosigner{
|
||||
{
|
||||
Account: priv0ScriptHash,
|
||||
Scopes: transaction.CalledByEntry,
|
||||
AllowedContracts: nil,
|
||||
AllowedGroups: nil,
|
||||
},
|
||||
}
|
||||
require.NoError(t, addNetworkFee(bc, txNeo0to1, acc0))
|
||||
require.NoError(t, acc0.SignTx(txNeo0to1))
|
||||
b = bc.newBlock(txNeo0to1)
|
||||
|
@ -429,26 +351,21 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Make a NEO roundtrip (send to myself) and claim GAS.
|
||||
txNeoRound = transaction.NewContractTX()
|
||||
txNeoRound.Nonce = getNextNonce()
|
||||
txNeoRound.ValidUntilBlock = validUntilBlock
|
||||
txNeoRound.Sender = priv0ScriptHash
|
||||
txNeoRound.AddInput(&transaction.Input{
|
||||
PrevHash: txNeo0to1.Hash(),
|
||||
PrevIndex: 1,
|
||||
})
|
||||
txNeoRound.AddOutput(&transaction.Output{
|
||||
AssetID: GoverningTokenID(),
|
||||
Amount: neoAmount - util.Fixed8FromInt64(1000),
|
||||
ScriptHash: priv0.GetScriptHash(),
|
||||
Position: 0,
|
||||
})
|
||||
txNeoRound.Data = new(transaction.ContractTX)
|
||||
require.NoError(t, addNetworkFee(bc, txNeoRound, acc0))
|
||||
require.NoError(t, acc0.SignTx(txNeoRound))
|
||||
// Prepare some transaction for future submission.
|
||||
txSendRaw := newNEP5Transfer(neoHash, priv0ScriptHash, priv1.GetScriptHash(), int64(util.Fixed8FromInt64(1000)))
|
||||
txSendRaw.ValidUntilBlock = validUntilBlock
|
||||
txSendRaw.Nonce = getNextNonce()
|
||||
txSendRaw.Sender = priv0ScriptHash
|
||||
txSendRaw.Cosigners = []transaction.Cosigner{{
|
||||
Account: priv0ScriptHash,
|
||||
Scopes: transaction.CalledByEntry,
|
||||
AllowedContracts: nil,
|
||||
AllowedGroups: nil,
|
||||
}}
|
||||
require.NoError(t, addNetworkFee(bc, txSendRaw, acc0))
|
||||
require.NoError(t, acc0.SignTx(txSendRaw))
|
||||
bw := io.NewBufBinWriter()
|
||||
txNeoRound.EncodeBinary(bw.BinWriter)
|
||||
txSendRaw.EncodeBinary(bw.BinWriter)
|
||||
t.Logf("sendrawtransaction: %s", hex.EncodeToString(bw.Bytes()))
|
||||
}
|
||||
|
||||
|
|
|
@ -55,39 +55,9 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
},
|
||||
}
|
||||
|
||||
rawScript, err := smartcontract.CreateMultiSigRedeemScript(
|
||||
len(cfg.StandbyValidators)/2+1,
|
||||
validators,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scriptOut := hash.Hash160(rawScript)
|
||||
|
||||
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.OLDPUSH1)})
|
||||
issueTx.Outputs = []transaction.Output{
|
||||
{
|
||||
AssetID: governingTokenTX.Hash(),
|
||||
Amount: governingTokenTX.Data.(*transaction.RegisterTX).Amount,
|
||||
ScriptHash: scriptOut,
|
||||
},
|
||||
}
|
||||
issueTx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: []byte{byte(opcode.OLDPUSH1)},
|
||||
},
|
||||
}
|
||||
|
||||
b := &block.Block{
|
||||
Base: base,
|
||||
Transactions: []*transaction.Transaction{
|
||||
&governingTokenTX,
|
||||
&utilityTokenTX,
|
||||
issueTx,
|
||||
deployNativeContracts(),
|
||||
},
|
||||
ConsensusData: block.ConsensusData{
|
||||
|
|
|
@ -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 := "472edea0e91369b51903b364e7403492a9041536fbfe145a9e1aff0ad5f18d78"
|
||||
expect := "d2e6d56c734f24c294a74785023af23f20347d97ef92e7bff1b337e37acbf2dd"
|
||||
assert.Equal(t, expect, block.Hash().StringLE())
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
|
||||
"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/internal/testchain"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
|
@ -54,12 +53,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getapplicationlog": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["1e71f60519a68c73cc1ca5382bab12160c4967c86e28e8238b78ea54dcbdc716"]`,
|
||||
params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`,
|
||||
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("1e71f60519a68c73cc1ca5382bab12160c4967c86e28e8238b78ea54dcbdc716")
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||
assert.Equal(t, 1, len(res.Executions))
|
||||
|
@ -139,11 +138,17 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
rubles, err := util.Uint160DecodeStringLE(testContractHash)
|
||||
require.NoError(t, err)
|
||||
expected := result.NEP5Balances{
|
||||
Balances: []result.NEP5Balance{{
|
||||
Asset: rubles,
|
||||
Amount: "8.77",
|
||||
LastUpdated: 208,
|
||||
},
|
||||
Balances: []result.NEP5Balance{
|
||||
{
|
||||
Asset: rubles,
|
||||
Amount: "8.77",
|
||||
LastUpdated: 6,
|
||||
},
|
||||
{
|
||||
Asset: e.chain.GoverningTokenHash(),
|
||||
Amount: "99998000",
|
||||
LastUpdated: 4,
|
||||
},
|
||||
{
|
||||
Asset: e.chain.UtilityTokenHash(),
|
||||
Amount: "1000",
|
||||
|
@ -176,47 +181,71 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
require.True(t, ok)
|
||||
rublesHash, err := util.Uint160DecodeStringLE(testContractHash)
|
||||
require.NoError(t, err)
|
||||
blockSendRubles, err := e.chain.GetBlock(e.chain.GetHeaderHash(208))
|
||||
blockSendRubles, err := e.chain.GetBlock(e.chain.GetHeaderHash(6))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(blockSendRubles.Transactions))
|
||||
txSendRublesHash := blockSendRubles.Transactions[0].Hash()
|
||||
blockRecieveRubles, err := e.chain.GetBlock(e.chain.GetHeaderHash(207))
|
||||
blockReceiveRubles, err := e.chain.GetBlock(e.chain.GetHeaderHash(5))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(blockRecieveRubles.Transactions))
|
||||
txRecieveRublesHash := blockRecieveRubles.Transactions[1].Hash()
|
||||
blockRecieveGAS, err := e.chain.GetBlock(e.chain.GetHeaderHash(1))
|
||||
require.Equal(t, 2, len(blockReceiveRubles.Transactions))
|
||||
txReceiveRublesHash := blockReceiveRubles.Transactions[1].Hash()
|
||||
blockReceiveGAS, err := e.chain.GetBlock(e.chain.GetHeaderHash(1))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(blockRecieveGAS.Transactions))
|
||||
txRecieveGASHash := blockRecieveGAS.Transactions[0].Hash()
|
||||
require.Equal(t, 2, len(blockReceiveGAS.Transactions))
|
||||
txReceiveNEOHash := blockReceiveGAS.Transactions[0].Hash()
|
||||
txReceiveGASHash := blockReceiveGAS.Transactions[1].Hash()
|
||||
blockSendNEO, err := e.chain.GetBlock(e.chain.GetHeaderHash(4))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(blockSendNEO.Transactions))
|
||||
txSendNEOHash := blockSendNEO.Transactions[0].Hash()
|
||||
expected := result.NEP5Transfers{
|
||||
Sent: []result.NEP5Transfer{{
|
||||
Timestamp: blockSendRubles.Timestamp,
|
||||
Asset: rublesHash,
|
||||
Address: testchain.PrivateKeyByID(1).Address(),
|
||||
Amount: "1.23",
|
||||
Index: 208,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txSendRublesHash,
|
||||
}},
|
||||
Sent: []result.NEP5Transfer{
|
||||
{
|
||||
Timestamp: blockSendRubles.Timestamp,
|
||||
Asset: rublesHash,
|
||||
Address: testchain.PrivateKeyByID(1).Address(),
|
||||
Amount: "1.23",
|
||||
Index: 6,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txSendRublesHash,
|
||||
},
|
||||
{
|
||||
Timestamp: blockSendNEO.Timestamp,
|
||||
Asset: e.chain.GoverningTokenHash(),
|
||||
Address: testchain.PrivateKeyByID(1).Address(),
|
||||
Amount: "1000",
|
||||
Index: 4,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txSendNEOHash,
|
||||
},
|
||||
},
|
||||
Received: []result.NEP5Transfer{
|
||||
{
|
||||
Timestamp: blockRecieveRubles.Timestamp,
|
||||
Timestamp: blockReceiveRubles.Timestamp,
|
||||
Asset: rublesHash,
|
||||
Address: address.Uint160ToString(rublesHash),
|
||||
Amount: "10",
|
||||
Index: 207,
|
||||
Index: 5,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txRecieveRublesHash,
|
||||
TxHash: txReceiveRublesHash,
|
||||
},
|
||||
{
|
||||
Timestamp: blockRecieveGAS.Timestamp,
|
||||
Timestamp: blockReceiveGAS.Timestamp,
|
||||
Asset: e.chain.UtilityTokenHash(),
|
||||
Address: testchain.MultisigAddress(),
|
||||
Amount: "1000",
|
||||
Index: 1,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txRecieveGASHash,
|
||||
TxHash: txReceiveGASHash,
|
||||
},
|
||||
{
|
||||
Timestamp: blockReceiveGAS.Timestamp,
|
||||
Asset: e.chain.GoverningTokenHash(),
|
||||
Address: testchain.MultisigAddress(),
|
||||
Amount: "99999000",
|
||||
Index: 1,
|
||||
NotifyIndex: 0,
|
||||
TxHash: txReceiveNEOHash,
|
||||
},
|
||||
},
|
||||
Address: testchain.PrivateKeyByID(0).Address(),
|
||||
|
@ -292,10 +321,9 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
|
||||
assert.Equal(t, block.Hash(), res.Hash())
|
||||
for i, tx := range res.Transactions {
|
||||
require.Equal(t, transaction.ContractType, tx.Type)
|
||||
|
||||
actualTx := block.Transactions[i]
|
||||
require.True(t, ok)
|
||||
require.Equal(t, actualTx.Type, tx.Type)
|
||||
require.Equal(t, actualTx.Nonce, tx.Nonce)
|
||||
require.Equal(t, block.Transactions[i].Hash(), tx.Hash())
|
||||
}
|
||||
|
@ -451,11 +479,16 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"gettransactionheight": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["be463055a8447567434037aad40ad58764cb7eef4aee64308f74ce6df5a98a8a"]`,
|
||||
params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
h := 1
|
||||
h := 0
|
||||
return &h
|
||||
},
|
||||
check: func(t *testing.T, e *executor, resp interface{}) {
|
||||
h, ok := resp.(*int)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, 2, *h)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no params",
|
||||
|
@ -494,7 +527,8 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
check: func(t *testing.T, e *executor, resp interface{}) {
|
||||
s, ok := resp.(*string)
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "1772", *s)
|
||||
// Incorrect, to be fixed later.
|
||||
assert.Equal(t, "0", *s)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -639,7 +673,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"sendrawtransaction": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["80000b000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000a267050000000000b0040000000001e2b5b6f72dc08d3b0e498c6466928031333f0b242cf158a547b8c4a1681f8f2d010001787cc0a786adfe829bc2dffc5637e6855c0a82e02deee97dedbc2aac3e0e5e1a0030d3dec3862300316e851039019d39dfc2c37d6c3fee19fd58098701420c406a41c10280ff445c36fb16fe94fa197c9ab9678d099c7c1af5d4b9269ac19bbba09e20f02f53582bc340b4ea77539c28bb2cc03902e77d5d37febabe902aac98290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`,
|
||||
params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
@ -647,7 +681,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
},
|
||||
{
|
||||
name: "negative",
|
||||
params: `["0274d792072617720636f6e7472616374207472616e73616374696f6e206465736372697074696f6e01949354ea0a8b57dfee1e257a1aedd1e0eea2e5837de145e8da9c0f101bfccc8e0100029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500a3e11100000000ea610aa6db39bd8c8556c9569d94b5e5a5d0ad199b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc5004f2418010000001cc9c05cefffe6cdd7b182816a9152ec218d2ec0014140dbd3cddac5cb2bd9bf6d93701f1a6f1c9dbe2d1b480c54628bbb2a4d536158c747a6af82698edf9f8af1cac3850bcb772bd9c8e4ac38f80704751cc4e0bd0e67232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"]`,
|
||||
params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad5"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
|
@ -811,7 +845,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "400000000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b000000000000000000000000000000000000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b0000000000", res)
|
||||
assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments", func(t *testing.T) {
|
||||
|
@ -823,7 +857,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "400000000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b000000000000000000000000000000000000000000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b0000000000", res)
|
||||
assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments, verbose", func(t *testing.T) {
|
||||
|
@ -835,19 +869,9 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
actual := result.TransactionOutputRaw{}
|
||||
err := json.Unmarshal(txOut, &actual)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", txOut)
|
||||
admin, err := util.Uint160DecodeStringBE("da1745e9b549bd0bfa1a569971c77eba30cd5a4b")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, transaction.RegisterType, actual.Transaction.Type)
|
||||
assert.Equal(t, &transaction.RegisterTX{
|
||||
AssetType: 0,
|
||||
Name: `[{"lang":"zh-CN","name":"小蚁股"},{"lang":"en","name":"AntShare"}]`,
|
||||
Amount: util.Fixed8FromInt64(100000000),
|
||||
Precision: 0,
|
||||
Owner: keys.PublicKey{},
|
||||
Admin: admin,
|
||||
}, actual.Transaction.Data.(*transaction.RegisterTX))
|
||||
assert.Equal(t, 210, actual.Confirmations)
|
||||
assert.Equal(t, block.Transactions[0], actual.Transaction)
|
||||
assert.Equal(t, 8, actual.Confirmations)
|
||||
assert.Equal(t, TXHash, actual.Transaction.Hash())
|
||||
})
|
||||
|
||||
|
|
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