mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
core: add transaction.HasSigner method
This commit is contained in:
parent
1956f2c079
commit
f259a614de
2 changed files with 22 additions and 0 deletions
|
@ -407,3 +407,13 @@ func (t *Transaction) isValid() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasSigner returns true in case if hash is present in the list of signers.
|
||||
func (t *Transaction) HasSigner(hash util.Uint160) bool {
|
||||
for _, h := range t.Signers {
|
||||
if h.Account.Equals(hash) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
@ -248,3 +249,14 @@ func TestTransaction_GetAttributes(t *testing.T) {
|
|||
require.Equal(t, conflictsAttrs, tx.GetAttributes(typ))
|
||||
})
|
||||
}
|
||||
|
||||
func TestTransaction_HasSigner(t *testing.T) {
|
||||
u1, u2 := random.Uint160(), random.Uint160()
|
||||
tx := Transaction{
|
||||
Signers: []Signer{
|
||||
{Account: u1}, {Account: u2},
|
||||
},
|
||||
}
|
||||
require.True(t, tx.HasSigner(u1))
|
||||
require.False(t, tx.HasSigner(util.Uint160{}))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue