forked from TrueCloudLab/neoneo-go
neotest: add API to check notification event
This commit is contained in:
parent
4df5d370c5
commit
4057e635af
1 changed files with 14 additions and 0 deletions
|
@ -2,6 +2,7 @@ package neotest
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -144,6 +145,19 @@ func (e *Executor) CheckFault(t *testing.T, h util.Uint256, s string) {
|
|||
"expected: %s, got: %s", s, aer[0].FaultException)
|
||||
}
|
||||
|
||||
// CheckTxNotificationEvent checks that specified event was emitted at the specified position
|
||||
// during transaction script execution. Negative index corresponds to backwards enumeration.
|
||||
func (e *Executor) CheckTxNotificationEvent(t *testing.T, h util.Uint256, index int, expected state.NotificationEvent) {
|
||||
aer, err := e.Chain.GetAppExecResults(h, trigger.Application)
|
||||
require.NoError(t, err)
|
||||
l := len(aer[0].Events)
|
||||
if index < 0 {
|
||||
index = l + index
|
||||
}
|
||||
require.True(t, 0 <= index && index < l, fmt.Errorf("notification index is out of range: want %d, len is %d", index, l))
|
||||
require.Equal(t, expected, aer[0].Events[index])
|
||||
}
|
||||
|
||||
// NewDeployTx returns new deployment tx for contract signed by committee.
|
||||
func (e *Executor) NewDeployTx(t *testing.T, bc blockchainer.Blockchainer, c *Contract, data interface{}) *transaction.Transaction {
|
||||
rawManifest, err := json.Marshal(c.Manifest)
|
||||
|
|
Loading…
Reference in a new issue