Skip to content

Commit 7809b33

Browse files
authored
Merge branch 'main' into tagemoua-patch1
2 parents 2317411 + d507ea6 commit 7809b33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2922
-1291
lines changed

.github/workflows/go_integration_tests.yml

+49-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,64 @@ name: Go Integration Test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
10-
11-
test:
12-
name: Tests
10+
integration:
11+
name: Integration test
1312
runs-on: ubuntu-latest
1413
steps:
1514
- name: Set up Go ^1.17
1615
uses: actions/setup-go@v2
1716
with:
1817
go-version: ^1.17
19-
18+
2019
- name: Check out code into the Go module directory
2120
uses: actions/checkout@v2
22-
21+
2322
- name: Run the integration test
24-
run: go test -timeout 7m -run TestIntegration ./integration/...
23+
run: go test -timeout 10m -run TestIntegration ./integration/...
24+
bad_vote:
25+
name: Test bad vote
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set up Go ^1.17
29+
uses: actions/setup-go@v2
30+
with:
31+
go-version: ^1.17
32+
33+
- name: Check out code into the Go module directory
34+
uses: actions/checkout@v2
35+
36+
- name: Run the bad vote test
37+
run: go test -timeout 10m -run TestBadVote ./integration/...
38+
crash:
39+
name: Test crash
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Set up Go ^1.17
43+
uses: actions/setup-go@v2
44+
with:
45+
go-version: ^1.17
46+
47+
- name: Check out code into the Go module directory
48+
uses: actions/checkout@v2
49+
50+
- name: Run the crash test
51+
run: go test -timeout 10m -run TestCrash ./integration/...
52+
revote:
53+
name: Test revote
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Set up Go ^1.17
57+
uses: actions/setup-go@v2
58+
with:
59+
go-version: ^1.17
60+
61+
- name: Check out code into the Go module directory
62+
uses: actions/checkout@v2
63+
64+
- name: Run the revote test
65+
run: go test -timeout 10m -run TestRevote ./integration/...

.github/workflows/go_scenario_test.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ name: Go Scenario Test (with proxy)
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
10-
1110
test:
1211
name: Tests
1312
runs-on: ubuntu-latest
@@ -22,18 +21,18 @@ jobs:
2221
git clone https://github.com/dedis/dela.git
2322
cd dela
2423
go install ./cli/crypto
25-
24+
2625
- name: Check out code into the Go module directory
2726
uses: actions/checkout@v2
28-
27+
2928
- name: Create a private key
3029
run: crypto bls signer new --save private.key
3130

3231
- name: Install memcoin
3332
run: make build
3433

35-
- name: Start and setup 3 nodes
36-
run: ./runSystems.sh -n 3 --docker false --backend false --frontend false --attach false
34+
- name: Start and setup 5 nodes
35+
run: ./runSystems.sh -n 5 --docker false --backend false --frontend false --attach false
3736

3837
- name: Run the scenario Test
3938
run: go test -timeout 7m -run TestScenario ./integration/...

contracts/evoting/controller/action.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/dedis/d-voting/contracts/evoting/types"
2121
"github.com/dedis/d-voting/internal/testing/fake"
2222
eproxy "github.com/dedis/d-voting/proxy"
23+
"github.com/dedis/d-voting/proxy/txnmanager"
2324
ptypes "github.com/dedis/d-voting/proxy/types"
2425
"github.com/dedis/d-voting/services/dkg"
2526
"github.com/dedis/d-voting/services/shuffle"
@@ -46,8 +47,11 @@ import (
4647
const (
4748
contentType = "application/json"
4849
formPath = "/evoting/forms"
49-
formPathSlash = formPath + "/"
50-
formIDPath = formPathSlash + "{formID}"
50+
// FormPathSlash is the path to the form with a trailing slash
51+
FormPathSlash = formPath + "/"
52+
formIDPath = FormPathSlash + "{formID}"
53+
transactionSlash = "/evoting/transactions/"
54+
transactionPath = transactionSlash + "{token}"
5155
unexpectedStatus = "unexpected status: %s, body: %s"
5256
failRetrieveDecryption = "failed to retrieve decryption key: %v"
5357
selectString = "select:"
@@ -91,7 +95,9 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
9195
return xerrors.Errorf("failed to resolve ordering.Service: %v", err)
9296
}
9397

94-
var blocks *blockstore.InDisk
98+
// The BlockStore will be used to parse the blockchain
99+
// to check if a transaction was included
100+
var blocks blockstore.BlockStore
95101
err = ctx.Injector.Resolve(&blocks)
96102
if err != nil {
97103
return xerrors.Errorf("failed to resolve blockstore.InDisk: %v", err)
@@ -163,7 +169,9 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
163169
return xerrors.Errorf("failed to unmarshal proxy key: %v", err)
164170
}
165171

166-
ep := eproxy.NewForm(ordering, mngr, p, sjson.NewContext(), formFac, proxykey)
172+
transactionManager := txnmanager.NewTransactionManager(mngr, p, sjson.NewContext(), proxykey, blocks, signer)
173+
174+
ep := eproxy.NewForm(ordering, p, sjson.NewContext(), formFac, proxykey, transactionManager)
167175

168176
router := mux.NewRouter()
169177

@@ -175,12 +183,14 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
175183
router.HandleFunc(formIDPath, eproxy.AllowCORS).Methods("OPTIONS")
176184
router.HandleFunc(formIDPath, ep.DeleteForm).Methods("DELETE")
177185
router.HandleFunc(formIDPath+"/vote", ep.NewFormVote).Methods("POST")
186+
router.HandleFunc(transactionPath, transactionManager.StatusHandlerGet).Methods("GET")
178187

179188
router.NotFoundHandler = http.HandlerFunc(eproxy.NotFoundHandler)
180189
router.MethodNotAllowedHandler = http.HandlerFunc(eproxy.NotAllowedHandler)
181190

182191
proxy.RegisterHandler(formPath, router.ServeHTTP)
183-
proxy.RegisterHandler(formPathSlash, router.ServeHTTP)
192+
proxy.RegisterHandler(FormPathSlash, router.ServeHTTP)
193+
proxy.RegisterHandler(transactionSlash, router.ServeHTTP)
184194

185195
dela.Logger.Info().Msg("d-voting proxy handlers registered")
186196

@@ -692,7 +702,7 @@ func marshallBallot(voteStr string, actor dkg.Actor, chunks int) (ptypes.Cipherv
692702

693703
// formID is hex-encoded
694704
func castVote(formID string, signed []byte, proxyAddr string) (string, error) {
695-
resp, err := http.Post(proxyAddr+formPathSlash+formID+"/vote", contentType, bytes.NewBuffer(signed))
705+
resp, err := http.Post(proxyAddr+FormPathSlash+formID+"/vote", contentType, bytes.NewBuffer(signed))
696706

697707
if err != nil {
698708
return "", xerrors.Errorf(failRetrieveDecryption, err)
@@ -723,7 +733,7 @@ func updateForm(secret kyber.Scalar, proxyAddr, formIDHex, action string) (int,
723733
return 0, createSignedErr(err)
724734
}
725735

726-
req, err := http.NewRequest(http.MethodPut, proxyAddr+formPathSlash+formIDHex, bytes.NewBuffer(signed))
736+
req, err := http.NewRequest(http.MethodPut, proxyAddr+FormPathSlash+formIDHex, bytes.NewBuffer(signed))
727737

728738
if err != nil {
729739
return 0, xerrors.Errorf("failed to create request: %v", err)

0 commit comments

Comments
 (0)