From ccf21861208562eed448c30bb03979a0779c08f4 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Wed, 28 Feb 2024 09:58:33 +0100 Subject: [PATCH] Fix tests --- .../contracts/viewchange/viewchange_test.go | 2 +- core/txn/signed/signed_test.go | 2 +- testing/fake/crypto.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/ordering/cosipbft/contracts/viewchange/viewchange_test.go b/core/ordering/cosipbft/contracts/viewchange/viewchange_test.go index 1f718ff81..2a21083a4 100644 --- a/core/ordering/cosipbft/contracts/viewchange/viewchange_test.go +++ b/core/ordering/cosipbft/contracts/viewchange/viewchange_test.go @@ -22,7 +22,7 @@ func TestRegisterContract(t *testing.T) { } func TestNewTransaction(t *testing.T) { - mgr := NewManager(signed.NewManager(fake.NewSigner(), nil)) + mgr := NewManager(signed.NewManager(fake.NewSigner(), fake.NewClient())) tx, err := mgr.Make(authority.New(nil, nil)) require.NoError(t, err) diff --git a/core/txn/signed/signed_test.go b/core/txn/signed/signed_test.go index b8c47227a..d32ac180b 100644 --- a/core/txn/signed/signed_test.go +++ b/core/txn/signed/signed_test.go @@ -160,7 +160,7 @@ func TestTransactionFactory_Deserialize(t *testing.T) { } func TestManager_Make(t *testing.T) { - mgr := NewManager(fake.NewSigner(), nil) + mgr := NewManager(fake.NewSigner(), fake.NewClient()) tx, err := mgr.Make(txn.Arg{Key: "a", Value: []byte{1, 2, 3}}) require.NoError(t, err) diff --git a/testing/fake/crypto.go b/testing/fake/crypto.go index 90a3f5acb..5fd36dc57 100644 --- a/testing/fake/crypto.go +++ b/testing/fake/crypto.go @@ -3,6 +3,7 @@ package fake import ( "hash" + "go.dedis.ch/dela/core/access" "go.dedis.ch/dela/crypto" "go.dedis.ch/dela/serde" ) @@ -253,6 +254,19 @@ func (s Signer) Aggregate(...crypto.Signature) (crypto.Signature, error) { return Signature{}, s.err } +type Client struct { + nonce uint64 +} + +// NewClient returns a fake client +func NewClient() Client { + return Client{} +} + +func (c Client) GetNonce(access.Identity) (uint64, error) { + return c.nonce, nil +} + // Verifier is a fake implementation of crypto.Verifier. // // - implements crypto.Verifier