Merge pull request #118 from prestonvanloon/fix/already-deposited

Only deposit as notary if not already deposited

Former-commit-id: eaaacb92c2f79f4664279a3bcc5973ad89241b42 [formerly b95f0e744d05df2590d868ed447fb2d8dffbceba]
Former-commit-id: 0d4c692f25a765f1e8529cdbc95d4593aeefd0f7
This commit is contained in:
Preston Van Loon 2018-05-13 16:36:59 -04:00 committed by GitHub
commit 5359cf04a9
2 changed files with 20 additions and 0 deletions

View File

@ -140,6 +140,10 @@ func joinNotaryPool(c client.Client) error {
return errors.New("joinNotaryPool called when deposit flag was not set")
}
if b, err := isAccountInNotaryPool(c); b || err != nil {
return err
}
log.Info("Joining notary pool")
txOps, err := c.CreateTXOpts(sharding.NotaryDeposit)
if err != nil {

View File

@ -138,4 +138,20 @@ func TestJoinNotaryPool(t *testing.T) {
if big.NewInt(1).Cmp(numNotaries) != 0 {
t.Fatalf("Unexpected number of notaries. Got %d, wanted 1.", numNotaries)
}
// Trying to join while deposited should do nothing
err = joinNotaryPool(client)
if err != nil {
t.Error(err)
}
backend.Commit()
numNotaries, err = smc.NotaryPoolLength(&bind.CallOpts{})
if err != nil {
t.Fatal(err)
}
if big.NewInt(1).Cmp(numNotaries) != 0 {
t.Fatalf("Unexpected number of notaries. Got %d, wanted 1.", numNotaries)
}
}