forked from TrueCloudLab/neoneo-go
core: add one more Contract tx to the test chain
When testing CLI it is useful to have some spent coins on an account with a known key.
This commit is contained in:
parent
37c2bc4733
commit
972e0d8ad1
2 changed files with 28 additions and 3 deletions
|
@ -158,6 +158,11 @@ func newDumbBlock() *block.Block {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getInvocationScript(data []byte, priv *keys.PrivateKey) []byte {
|
||||||
|
signature := priv.Sign(data)
|
||||||
|
return append([]byte{byte(opcode.PUSHBYTES64)}, signature...)
|
||||||
|
}
|
||||||
|
|
||||||
// This function generates "../rpc/testdata/testblocks.acc" file which contains data
|
// This function generates "../rpc/testdata/testblocks.acc" file which contains data
|
||||||
// for RPC unit tests.
|
// for RPC unit tests.
|
||||||
// To generate new "../rpc/testdata/testblocks.acc", follow the steps:
|
// To generate new "../rpc/testdata/testblocks.acc", follow the steps:
|
||||||
|
@ -246,9 +251,7 @@ func _(t *testing.T) {
|
||||||
for i := range privNetKeys {
|
for i := range privNetKeys {
|
||||||
priv, err := keys.NewPrivateKeyFromWIF(privNetKeys[i])
|
priv, err := keys.NewPrivateKeyFromWIF(privNetKeys[i])
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
signature := priv.Sign(data)
|
invoc = append(invoc, getInvocationScript(data, priv)...)
|
||||||
invoc = append(invoc, byte(opcode.PUSHBYTES64))
|
|
||||||
invoc = append(invoc, signature...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tx4.Scripts = []transaction.Witness{{
|
tx4.Scripts = []transaction.Witness{{
|
||||||
|
@ -259,6 +262,28 @@ func _(t *testing.T) {
|
||||||
b := bc.newBlock(newMinerTX(), tx3, tx4)
|
b := bc.newBlock(newMinerTX(), tx3, tx4)
|
||||||
require.NoError(t, bc.AddBlock(b))
|
require.NoError(t, bc.AddBlock(b))
|
||||||
|
|
||||||
|
priv1, err := keys.NewPrivateKeyFromWIF(privNetKeys[1])
|
||||||
|
require.NoError(t, err)
|
||||||
|
tx5 := transaction.NewContractTX()
|
||||||
|
tx5.Data = new(transaction.ContractTX)
|
||||||
|
tx5.AddInput(&transaction.Input{
|
||||||
|
PrevHash: tx4.Hash(),
|
||||||
|
PrevIndex: 0,
|
||||||
|
})
|
||||||
|
tx5.AddOutput(&transaction.Output{
|
||||||
|
AssetID: GoverningTokenID(),
|
||||||
|
Amount: util.Fixed8FromInt64(1000),
|
||||||
|
ScriptHash: priv1.GetScriptHash(),
|
||||||
|
})
|
||||||
|
|
||||||
|
tx5.Scripts = []transaction.Witness{{
|
||||||
|
InvocationScript: getInvocationScript(tx5.GetSignedPart(), priv),
|
||||||
|
VerificationScript: priv.PublicKey().GetVerificationScript(),
|
||||||
|
}}
|
||||||
|
|
||||||
|
b = bc.newBlock(newMinerTX(), tx5)
|
||||||
|
require.NoError(t, bc.AddBlock(b))
|
||||||
|
|
||||||
outStream, err := os.Create(prefix + "testblocks.acc")
|
outStream, err := os.Create(prefix + "testblocks.acc")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer outStream.Close()
|
defer outStream.Close()
|
||||||
|
|
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