actor: add Sender helper method

This commit is contained in:
Roman Khimov 2022-08-19 16:45:16 +03:00
parent c034f94a94
commit b2524a3ba9
2 changed files with 17 additions and 0 deletions

View file

@ -202,3 +202,9 @@ func (a *Actor) SendTunedRun(script []byte, attrs []transaction.Attribute, txHoo
func (a *Actor) SendUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, txHook TransactionModifier) (util.Uint256, uint32, error) {
return a.sendWrapper(a.MakeUncheckedRun(script, sysfee, attrs, txHook))
}
// Sender return the sender address that will be used in transactions created
// by Actor.
func (a *Actor) Sender() util.Uint160 {
return a.txSigners[0].Account
}

View file

@ -7,6 +7,7 @@ import (
"github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util"
@ -259,3 +260,13 @@ func TestSenders(t *testing.T) {
require.Equal(t, client.hash, h)
require.Equal(t, uint32(8), vub)
}
func TestSender(t *testing.T) {
client, acc := testRPCAndAccount(t)
a, err := NewSimple(client, acc)
require.NoError(t, err)
addr, err := address.StringToUint160(acc.Address)
require.NoError(t, err)
require.Equal(t, addr, a.Sender())
}