From 7de6d3475847eb9dea24115b960bc04a03c36f71 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 26 May 2022 08:07:34 +0000 Subject: [PATCH] test: add tests on ReceiveFromTreasuryAuthorization --- x/foundation/authz_test.go | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x/foundation/authz_test.go diff --git a/x/foundation/authz_test.go b/x/foundation/authz_test.go new file mode 100644 index 0000000000..fa3342f24c --- /dev/null +++ b/x/foundation/authz_test.go @@ -0,0 +1,39 @@ +package foundation_test + +import ( + "testing" + + sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/x/foundation" + "github.com/stretchr/testify/require" +) + +func TestReceiveFromTreasuryAuthorization(t *testing.T) { + testCases := map[string]struct{ + msg sdk.Msg + valid bool + accept bool + }{ + "valid": { + msg: &foundation.MsgWithdrawFromTreasury{}, + valid: true, + accept: true, + }, + "msg mismatch": { + msg: &foundation.MsgVote{}, + }, + } + + for name, tc := range testCases { + authorization := &foundation.ReceiveFromTreasuryAuthorization{} + + resp, err := authorization.Accept(sdk.Context{}, tc.msg) + if !tc.valid { + require.Error(t, err, name) + continue + } + require.NoError(t, err, name) + + require.Equal(t, tc.accept, resp.Accept) + } +}