Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Feb 29, 2024
1 parent c27f860 commit fb6aaf7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.19
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
env:
LLVL: trace
steps:
- name: Set up Go ^1.19
- name: Set up Go '1.20'
uses: actions/setup-go@v3
with:
go-version: ^1.19
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions core/ordering/cosipbft/cosipbft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestService_Scenario_ViewChange_Request(t *testing.T) {
require.Equal(t, leader, nodes[0].onet.GetAddress())

// let enough time for a round to run
time.Sleep(DefaultRoundTimeout + 100*time.Millisecond)
time.Sleep(time.Second)

require.Equal(t, nodes[3].service.pbftsm.GetState(), pbft.ViewChangeState)
require.NotEqual(t, nodes[2].service.pbftsm.GetState(), pbft.ViewChangeState)
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestService_Scenario_ViewChange_NoRequest(t *testing.T) {
require.NoError(t, err)

// let enough time for a round to run
time.Sleep(DefaultRoundTimeout + 100*time.Millisecond)
time.Sleep(time.Second)

require.NotEqual(t, nodes[3].service.pbftsm.GetState(), pbft.ViewChangeState)
require.NotEqual(t, nodes[2].service.pbftsm.GetState(), pbft.ViewChangeState)
Expand Down
2 changes: 1 addition & 1 deletion core/txn/signed/signed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions test/cosidela_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,13 @@ func (a accessstore) Delete(key []byte) error {
return nil
}

// txClient return monotically increasing nonce
// txClient returns always a 0 nonce
//
// - implements signed.Client
type txClient struct {
nonce uint64
}

// GetNonce implements signed.Client
func (c *txClient) GetNonce(access.Identity) (uint64, error) {
res := c.nonce
c.nonce++
return res, nil
return 0, nil
}
3 changes: 0 additions & 3 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ func addAndWait(
node cosiDelaNode,
args ...txn.Arg,
) error {
err := manager.Sync()
require.NoError(t, err)

tx, err := manager.Make(args...)
if err != nil {
return xerrors.Errorf("failed to make tx: %v", err)
Expand Down
14 changes: 14 additions & 0 deletions testing/fake/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fake
import (
"hash"

"go.dedis.ch/dela/core/access"
"go.dedis.ch/dela/crypto"
"go.dedis.ch/dela/serde"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb6aaf7

Please sign in to comment.