Merge pull request #9482 from filecoin-project/gstuart/fix-grant-datacap

fix: actors: fix verifreg checking notary balance
This commit is contained in:
Aayush Rajasekaran 2022-10-13 14:14:39 -04:00 committed by GitHub
commit e549a3fb4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -28,15 +28,8 @@ func getDataCap(store adt.Store, ver actors.Version, root rootFunc, addr address
return false, big.Zero(), xerrors.Errorf("loading verifreg: %w", err)
}
var keyedAddr abi.Keyer
if ver <= 8 {
keyedAddr = abi.AddrKey(addr)
} else {
keyedAddr = abi.IdAddrKey(addr)
}
var dcap abi.StoragePower
if found, err := vh.Get(keyedAddr, &dcap); err != nil {
if found, err := vh.Get(abi.AddrKey(addr), &dcap); err != nil {
return false, big.Zero(), xerrors.Errorf("looking up addr: %w", err)
} else if !found {
return false, big.Zero(), nil

View File

@ -226,7 +226,8 @@ func TestRemoveDataCap(t *testing.T) {
// make the 2 verifiers
makeVerifier := func(addr address.Address) error {
params, aerr := actors.SerializeParams(&verifregst.AddVerifierParams{Address: addr, Allowance: big.NewInt(100000000000)})
allowance := big.NewInt(100000000000)
params, aerr := actors.SerializeParams(&verifregst.AddVerifierParams{Address: addr, Allowance: allowance})
require.NoError(t, aerr)
msg := &types.Message{
@ -245,6 +246,10 @@ func TestRemoveDataCap(t *testing.T) {
require.NoError(t, err)
require.EqualValues(t, 0, res.Receipt.ExitCode)
verifierAllowance, err := api.StateVerifierStatus(ctx, addr, types.EmptyTSK)
require.NoError(t, err)
require.Equal(t, allowance, *verifierAllowance)
return nil
}