mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
neotest: check deployed contract hash
This commit is contained in:
parent
4057e635af
commit
1194361826
2 changed files with 13 additions and 5 deletions
|
@ -20,10 +20,7 @@ func newNSClient(t *testing.T) *neotest.ContractInvoker {
|
||||||
c := neotest.CompileFile(t, e.CommitteeHash, "..", "../nns.yml")
|
c := neotest.CompileFile(t, e.CommitteeHash, "..", "../nns.yml")
|
||||||
e.DeployContract(t, c, nil)
|
e.DeployContract(t, c, nil)
|
||||||
|
|
||||||
h, err := e.Chain.GetContractScriptHash(1)
|
return e.CommitteeInvoker(c.Hash)
|
||||||
require.NoError(t, err)
|
|
||||||
require.Equal(t, c.Hash, h)
|
|
||||||
return e.CommitteeInvoker(h)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNameService_Price(t *testing.T) {
|
func TestNameService_Price(t *testing.T) {
|
||||||
|
|
|
@ -114,13 +114,24 @@ func (e *Executor) NewAccount(t *testing.T) Signer {
|
||||||
return NewSingleSigner(acc)
|
return NewSingleSigner(acc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeployContract compiles and deploys contract to bc.
|
// DeployContract compiles and deploys contract to bc. It also checks that
|
||||||
|
// precalculated contract hash matches the actual one.
|
||||||
// data is an optional argument to `_deploy`.
|
// data is an optional argument to `_deploy`.
|
||||||
// Returns hash of the deploy transaction.
|
// Returns hash of the deploy transaction.
|
||||||
func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) util.Uint256 {
|
func (e *Executor) DeployContract(t *testing.T, c *Contract, data interface{}) util.Uint256 {
|
||||||
tx := e.NewDeployTx(t, e.Chain, c, data)
|
tx := e.NewDeployTx(t, e.Chain, c, data)
|
||||||
e.AddNewBlock(t, tx)
|
e.AddNewBlock(t, tx)
|
||||||
e.CheckHalt(t, tx.Hash())
|
e.CheckHalt(t, tx.Hash())
|
||||||
|
|
||||||
|
// Check that precalculated hash matches the real one.
|
||||||
|
e.CheckTxNotificationEvent(t, tx.Hash(), -1, state.NotificationEvent{
|
||||||
|
ScriptHash: e.NativeHash(t, nativenames.Management),
|
||||||
|
Name: "Deploy",
|
||||||
|
Item: stackitem.NewArray([]stackitem.Item{
|
||||||
|
stackitem.NewByteArray(c.Hash.BytesBE()),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
return tx.Hash()
|
return tx.Hash()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue