Skip to content

Commit

Permalink
Updating cli tools tests to use new dela
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Jan 22, 2024
1 parent a5e99b6 commit 1cea2f6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
31 changes: 26 additions & 5 deletions cli/dvoting/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"encoding/base64"
"fmt"
"io"
"net"
Expand All @@ -14,6 +15,7 @@ import (
"time"

"github.com/stretchr/testify/require"
"go.dedis.ch/kyber/v3/pairing/bn256"
)

func TestDvoting_Main(t *testing.T) {
Expand Down Expand Up @@ -61,7 +63,7 @@ func TestDvoting_Scenario_SetupAndTransactions(t *testing.T) {
shareCert(t, node3, node1, "//127.0.0.1:2111")
shareCert(t, node5, node1, "//127.0.0.1:2111")

// Setup the chain with nodes 1 and 2.
// Set up the chain with nodes 1 and 2.
args := append(append(
append(
[]string{os.Args[0], "--config", node1, "ordering", "setup"},
Expand All @@ -85,7 +87,26 @@ func TestDvoting_Scenario_SetupAndTransactions(t *testing.T) {
err = run(args)
require.NoError(t, err)

// Add the certificate and push two new blocks to make sure node4 is
// fully participating
shareCert(t, node4, node1, "//127.0.0.1:2111")
publicKey, err := bn256.NewSuiteG2().Point().MarshalBinary()
require.NoError(t, err)
publicKeyHex := base64.StdEncoding.EncodeToString(publicKey)
argsAccess := []string{
os.Args[0],
"--config", node1, "access", "add",
"--identity", publicKeyHex,
}
for i := 0; i < 2; i++ {
err = runWithCfg(argsAccess, config{})
require.NoError(t, err)
}

// Add node 5 which should be participating.
// This makes sure that node 4 is actually participating and caught up.
// If node 4 is not participating, there would be too many faulty nodes
// after adding node 5.
args = append([]string{
os.Args[0],
"--config", node1, "ordering", "roster", "add",
Expand All @@ -96,10 +117,10 @@ func TestDvoting_Scenario_SetupAndTransactions(t *testing.T) {
err = run(args)
require.NoError(t, err)

// Run a few transactions.
for i := 0; i < 5; i++ {
err = runWithCfg(args, config{})
require.EqualError(t, err, "command error: transaction refused: duplicate in roster: grpcs://127.0.0.1:2115")
// Run 2 new transactions
for i := 0; i < 2; i++ {
err = runWithCfg(argsAccess, config{})
require.NoError(t, err)
}

// Test a timeout waiting for a transaction.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
)

replace (
go.dedis.ch/dela => github.com/c4dt/dela v0.0.0-20231121144634-18760d54394e
go.dedis.ch/dela => github.com/c4dt/dela v0.0.0-20231208150034-8c94bd32e18a
go.dedis.ch/dela-apps => github.com/c4dt/dela-apps v0.0.0-20231121155105-f3a8a6f4b3b8
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/c4dt/dela v0.0.0-20231121144634-18760d54394e h1:fziIs5dB/cYete4q4FveEefw0i4gbhbSjkTTJrfd4hQ=
github.com/c4dt/dela v0.0.0-20231121144634-18760d54394e/go.mod h1:Oh/WK8JMO0POQg7nR3u436u+HwsZwPqPzDWAasgmFAU=
github.com/c4dt/dela v0.0.0-20231208150034-8c94bd32e18a h1:MU7JHdKZssVjSeQttHPPa4fUMwqEO/xBQpdQ15H/AUo=
github.com/c4dt/dela v0.0.0-20231208150034-8c94bd32e18a/go.mod h1:Oh/WK8JMO0POQg7nR3u436u+HwsZwPqPzDWAasgmFAU=
github.com/c4dt/dela-apps v0.0.0-20231121155105-f3a8a6f4b3b8 h1:ELho4tnVG7lM3c2I42Q5IGNyuk/2FQCterA2zVQGvms=
github.com/c4dt/dela-apps v0.0.0-20231121155105-f3a8a6f4b3b8/go.mod h1:Rky9YH7R02zSOirr2BhhdJs/9VH4+rxqkQxHU3UTQRA=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down

0 comments on commit 1cea2f6

Please sign in to comment.