Sharding: Add check if already deposited

Former-commit-id: 32d3ec5c6bcbeb8e77aa7873e395e2b2cd362571 [formerly 623faf56f979a6e3f7bf4f903aac5c967da40dd2]
Former-commit-id: 5a60c62411845f441bca4f0a5540cf79ad9e0658
This commit is contained in:
Preston Van Loon 2018-05-13 14:23:20 -04:00
parent 4bfb23a5e7
commit 6de61b5d43
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)
}
}