Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Remove the delivered map from mailbox keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
misko9 committed Oct 17, 2023
1 parent 9553141 commit 2ef6e85
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion x/mailbox/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) error {
k.StoreTree(ctx, gs.Tree)

store := ctx.KVStore(k.storeKey)
// Delivered Messages.
for _, msgDelivered := range gs.DeliveredMessages {
k.Delivered[msgDelivered.Id] = true
store.Set(types.MailboxDeliveredKey(msgDelivered.Id), []byte{1})
}
// Domain
k.SetDomain(ctx, gs.Domain)
Expand Down
15 changes: 14 additions & 1 deletion x/mailbox/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ func (suite *KeeperTestSuite) TestGenesis() {
// Comparing the two states to make sure they are the same
tree := suite.keeper.GetImtTree(suite.ctx)
suite.Require().Equal(8, countKeeperPopulatedSlices(tree.Branch))
suite.Require().Equal(128, len(suite.keeper.Delivered))

// Verify each delivered message is found
for i := 0; i < 128; i++ {
id, err := hexutil.Decode(idMap[i])
suite.Require().NoError(err)
req := types.QueryMsgDeliveredRequest{
MessageId: id,
}
resp, err := suite.queryClient.MsgDelivered(suite.ctx, &req)
suite.Require().NoError(err)
suite.Require().True(resp.Delivered, "Message delivered was not found")
}

// Check that the branches match
isEqual := reflect.DeepEqual(gs.Tree.Branch, tree.Branch[:])
suite.Require().True(isEqual, "Imported state is not the same as exported state")
}
Expand Down
3 changes: 0 additions & 3 deletions x/mailbox/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type Keeper struct {
authority string
mailboxAddr sdk.AccAddress
version byte

Delivered map[string]bool
}

type ReadOnlyMailboxKeeper interface {
Expand All @@ -66,7 +64,6 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, cwKeeper *cosmwas
mailboxAddr: authtypes.NewModuleAddress(types.ModuleName),
version: 0,
pcwKeeper: cosmwasm.NewDefaultPermissionKeeper(cwKeeper),
Delivered: map[string]bool{},
}
}

Expand Down
1 change: 0 additions & 1 deletion x/mailbox/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func (k Keeper) Process(goCtx context.Context, msg *types.MsgProcess) (*types.Ms
// Store that the message was delivered
store := ctx.KVStore(k.storeKey)
store.Set(types.MailboxDeliveredKey(id), []byte{1})
k.Delivered[id] = true

// Emit the events
ctx.EventManager().EmitEvents(sdk.Events{
Expand Down

0 comments on commit 2ef6e85

Please sign in to comment.