Skip to content

Commit

Permalink
feat: genesis_test: check that all accounts are present in indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjat committed Nov 29, 2022
1 parent 07e56e0 commit 50aefed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ func validateAccounts(t *testing.T, genesis *stakingAPI.Genesis, source *oasis.C
FROM %s.accounts_checkpoint`, chainID),
)
require.Nil(t, err)
actualAccts := make(map[string]bool)
for acctRows.Next() {
var a TestAccount
err = acctRows.Scan(
Expand All @@ -576,6 +577,7 @@ func validateAccounts(t *testing.T, genesis *stakingAPI.Genesis, source *oasis.C
&a.Debonding,
)
assert.Nil(t, err)
actualAccts[a.Address] = true

isReservedAddress :=
a.Address == stakingAPI.CommonPoolAddress.String() ||
Expand Down Expand Up @@ -614,7 +616,8 @@ func validateAccounts(t *testing.T, genesis *stakingAPI.Genesis, source *oasis.C

acct, ok := genesis.Ledger[address]
if !ok {
t.Logf("address %s expected, but not found", address.String())
t.Logf("address %s found, but not expected", address.String())
t.Fail()
continue
}

Expand All @@ -633,6 +636,20 @@ func validateAccounts(t *testing.T, genesis *stakingAPI.Genesis, source *oasis.C
}
assert.Equal(t, e, a)
}
for addr, acct := range genesis.Ledger {
hasBalance :=
!acct.General.Balance.IsZero() ||
!acct.Escrow.Active.Balance.IsZero() ||
!acct.Escrow.Debonding.Balance.IsZero()
if !hasBalance { // the indexer doesn't have to know about this acct
continue
}

if !actualAccts[addr.String()] {
t.Logf("address %s expected, but not found", addr.String())
t.Fail()
}
}
}

func validateGovernanceBackend(t *testing.T, genesis *governanceAPI.Genesis, source *oasis.ConsensusClient, target *postgres.Client) {
Expand Down

0 comments on commit 50aefed

Please sign in to comment.