diff --git a/sharding/notary/notary.go b/sharding/notary/notary.go index dd428e97a..7573ed9d3 100644 --- a/sharding/notary/notary.go +++ b/sharding/notary/notary.go @@ -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 { diff --git a/sharding/notary/notary_test.go b/sharding/notary/notary_test.go index a32e5d6ea..21fa7d6fd 100644 --- a/sharding/notary/notary_test.go +++ b/sharding/notary/notary_test.go @@ -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) + } + }