Skip to content

Commit c00829e

Browse files
committed
services: untie verifyIncompleteWitnesses from Notary service
Signed-off-by: Anna Shaleva <[email protected]>
1 parent 7ebae8c commit c00829e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pkg/services/notary/notary.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (n *Notary) OnNewRequest(payload *payload.P2PNotaryRequest) {
246246

247247
nvbFallback := payload.FallbackTransaction.GetAttributes(transaction.NotValidBeforeT)[0].Value.(*transaction.NotValidBefore).Height
248248
nKeys := payload.MainTransaction.GetAttributes(transaction.NotaryAssistedT)[0].Value.(*transaction.NotaryAssisted).NKeys
249-
newInfo, validationErr := n.verifyIncompleteWitnesses(payload.MainTransaction, nKeys)
249+
newInfo, validationErr := verifyIncompleteWitnesses(payload.MainTransaction, nKeys)
250250
if validationErr != nil {
251251
n.Config.Log.Info("verification of main notary transaction failed; fallback transaction will be completed",
252252
zap.String("main hash", payload.MainTransaction.Hash().StringLE()),
@@ -508,7 +508,7 @@ func updateTxSize(tx *transaction.Transaction) (*transaction.Transaction, error)
508508
// verifyIncompleteWitnesses checks that the tx either doesn't have all witnesses attached (in this case none of them
509509
// can be multisignature) or it only has a partial multisignature. It returns the request type (sig/multisig), the
510510
// number of signatures to be collected, sorted public keys (for multisig request only) and an error.
511-
func (n *Notary) verifyIncompleteWitnesses(tx *transaction.Transaction, nKeysExpected uint8) ([]witnessInfo, error) {
511+
func verifyIncompleteWitnesses(tx *transaction.Transaction, nKeysExpected uint8) ([]witnessInfo, error) {
512512
var nKeysActual uint8
513513
if len(tx.Signers) < 2 {
514514
return nil, errors.New("transaction should have at least 2 signers")

pkg/services/notary/notary_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ func TestWallet(t *testing.T) {
4747
}
4848

4949
func TestVerifyIncompleteRequest(t *testing.T) {
50-
bc := fakechain.NewFakeChain()
5150
notaryContractHash := nativehashes.Notary
52-
_, ntr, _ := getTestNotary(t, bc, "./testdata/notary1.json", "one")
5351
sig := append([]byte{byte(opcode.PUSHDATA1), keys.SignatureLen}, make([]byte, keys.SignatureLen)...) // we're not interested in signature correctness
5452
acc1, _ := keys.NewPrivateKey()
5553
acc2, _ := keys.NewPrivateKey()
@@ -65,7 +63,7 @@ func TestVerifyIncompleteRequest(t *testing.T) {
6563
multisigScriptHash2 := hash.Hash160(multisigScript2)
6664

6765
checkErr := func(t *testing.T, tx *transaction.Transaction, nKeys uint8) {
68-
witnessInfo, err := ntr.verifyIncompleteWitnesses(tx, nKeys)
66+
witnessInfo, err := verifyIncompleteWitnesses(tx, nKeys)
6967
require.Error(t, err)
7068
require.Nil(t, witnessInfo)
7169
}
@@ -475,7 +473,7 @@ func TestVerifyIncompleteRequest(t *testing.T) {
475473

476474
for name, testCase := range testCases {
477475
t.Run(name, func(t *testing.T) {
478-
actualInfo, err := ntr.verifyIncompleteWitnesses(testCase.tx, testCase.nKeys)
476+
actualInfo, err := verifyIncompleteWitnesses(testCase.tx, testCase.nKeys)
479477
require.NoError(t, err)
480478
require.Equal(t, len(testCase.expectedInfo), len(actualInfo))
481479
for i, expected := range testCase.expectedInfo {

0 commit comments

Comments
 (0)