Skip to content

Commit

Permalink
update msgSetSendEnabled test case
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentysc committed Oct 24, 2023
1 parent a817e1f commit 9b6ede4
Show file tree
Hide file tree
Showing 3 changed files with 2,387 additions and 1 deletion.
3 changes: 2 additions & 1 deletion usecase/event/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func RegisterEvents(registry *event.Registry) {
registry.Register(MSG_SEND_CREATED, 1, DecodeMsgSend)
registry.Register(MSG_SEND_FAILED, 1, DecodeMsgSend)
registry.Register(MSG_MULTI_SEND_CREATED, 1, DecodeMsgMultiSend)
registry.Register(MSG_MULTI_SEND_FAILED, 1, DecodeMsgMultiSend)
registry.Register(MSG_SET_SEND_ENABLED_CREATED, 1, DecodeMsgSetSendEnabled)
registry.Register(MSG_SET_SEND_ENABLED_FAILED, 1, DecodeMsgSetSendEnabled)

// Distribution
registry.Register(MSG_SET_WITHDRAW_ADDRESS_CREATED, 1, DecodeMsgSetWithdrawAddress)
Expand Down
67 changes: 67 additions & 0 deletions usecase/parser/msg_set_send_enabled_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package parser_test

import (
"github.com/crypto-com/chain-indexing/infrastructure/tendermint"
"github.com/crypto-com/chain-indexing/usecase/model"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/crypto-com/chain-indexing/entity/command"
command_usecase "github.com/crypto-com/chain-indexing/usecase/command"
"github.com/crypto-com/chain-indexing/usecase/event"
"github.com/crypto-com/chain-indexing/usecase/parser"
usecase_parser_test "github.com/crypto-com/chain-indexing/usecase/parser/test"
)

var _ = Describe("ParseMsgCommands", func() {
Describe("MsgSetSendEnabled", func() {

It("should parse Msg commands when there is bank.MsgSetSendEnabled in the transaction", func() {
block, _ := mustParseBlockResp(usecase_parser_test.TX_MSG_SET_SEND_ENABLED_BLOCK_RESP)
blockResults := mustParseBlockResultsResp(usecase_parser_test.TX_MSG_SET_SEND_ENABlED_BLOCK_RESULTS_RESP, &tendermint.Base64BlockResultEventAttributeDecoder{})

tx := MustParseTxsResp(usecase_parser_test.TX_MSG_SET_SEND_ENABLED_TXS_RESP)
txs := []model.CosmosTxWithHash{*tx}

accountAddressPrefix := "tcro"
bondingDenom := "basetcro"

pm := usecase_parser_test.InitParserManager()

cmds, possibleSignerAddresses, err := parser.ParseBlockTxsMsgToCommands(
pm,
block.Height,
blockResults,
txs,
accountAddressPrefix,
bondingDenom,
)
Expect(err).To(BeNil())
Expect(cmds).To(HaveLen(1))
Expect(cmds).To(Equal([]command.Command{command_usecase.NewCreateMsgSetSendEnabled(
event.MsgCommonParams{
BlockHeight: int64(377673),
TxHash: "2A2A64A310B3D0E84C9831F4353E188A6E63BF451975C859DF40C54047AC6324",
TxSuccess: true,
MsgIndex: 0,
},
model.MsgSetSendEnabled{
Authority: "tcrc10d07y265gmmuvt4z0w9aw880jnsr700jrfqhyu",
SendEnabled: []model.SendEnabled{
{
Denom: "stake",
Enabled: true,
},
{
Denom: "basetcro",
Enabled: false,
},
},
UseDefaultFor: []string{},
},
)}))
Expect(possibleSignerAddresses).To(Equal([]string{"tcrc10d07y265gmmuvt4z0w9aw880jnsr700jrfqhyu"}))
})

})
})
Loading

0 comments on commit 9b6ede4

Please sign in to comment.