Skip to content

Commit

Permalink
Remove AccAddress.String()
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed Feb 27, 2024
1 parent 284e3ce commit 92ac6e0
Show file tree
Hide file tree
Showing 16 changed files with 393 additions and 376 deletions.
16 changes: 8 additions & 8 deletions tests/e2e/collection/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *E2ETestSuite) TestBalanceGRPC() {
}{
{
"valid request",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.customer.String(), tokenID),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.customer, tokenID),
false,
&collection.QueryBalanceResponse{},
&collection.QueryBalanceResponse{
Expand All @@ -37,7 +37,7 @@ func (s *E2ETestSuite) TestBalanceGRPC() {
},
{
"not own NFT",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.stranger.String(), tokenID),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.stranger, tokenID),
false,
&collection.QueryBalanceResponse{},
&collection.QueryBalanceResponse{
Expand All @@ -46,14 +46,14 @@ func (s *E2ETestSuite) TestBalanceGRPC() {
},
{
"invalid contract ID",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, "wrong id", s.customer.String(), tokenID),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, "wrong id", s.customer, tokenID),
true,
&collection.QueryBalanceResponse{},
&collection.QueryBalanceResponse{},
},
{
"invalid token ID",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.customer.String(), "wrong id"),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, s.contractID, s.customer, "wrong id"),
true,
&collection.QueryBalanceResponse{},
&collection.QueryBalanceResponse{},
Expand Down Expand Up @@ -97,13 +97,13 @@ func (s *E2ETestSuite) TestBalancesGRPC() {
}{
{
"valid request",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s", val.APIAddress, s.contractID, s.vendor.String()),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s", val.APIAddress, s.contractID, s.vendor),
false,
&collection.QueryAllBalancesResponse{},
},
{
"invalid contract ID",
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, "wrong id", s.vendor.String(), tokenID),
fmt.Sprintf("%s/lbm/collection/v1/contracts/%s/balances/%s/%s", val.APIAddress, "wrong id", s.vendor, tokenID),
true,
&collection.QueryAllBalancesResponse{},
},
Expand Down Expand Up @@ -430,7 +430,7 @@ func (s *E2ETestSuite) TestTokenGRPC() {
&collection.OwnerNFT{
ContractId: s.contractID,
TokenId: tokenID,
Owner: s.vendor.String(),
Owner: s.vendor,
Name: "arctic fox",
Meta: "",
},
Expand Down Expand Up @@ -505,7 +505,7 @@ func (s *E2ETestSuite) TestGranteeGrantsGRPC() {
&collection.QueryGranteeGrantsResponse{
Grants: []collection.Grant{
{
Grantee: s.stranger.String(),
Grantee: s.stranger,
Permission: collection.PermissionIssue,
},
},
Expand Down
51 changes: 27 additions & 24 deletions tests/e2e/collection/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ type E2ETestSuite struct {

commonArgs []string

vendor sdk.AccAddress
operator sdk.AccAddress
customer sdk.AccAddress
stranger sdk.AccAddress
vendor string
operator string
customer string
stranger string
contractID string
nftClassID string
tokenIDs map[string]string
Expand Down Expand Up @@ -63,7 +63,8 @@ func (s *E2ETestSuite) SetupSuite() {
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, cmath.NewInt(100))).String()),
}

s.vendor = s.network.Validators[0].Address
s.vendor, err = s.ac.BytesToString(s.network.Validators[0].Address)
s.Require().NoError(err)
s.operator = s.createAccount("operator")
s.customer = s.createAccount("customer")
s.stranger = s.createAccount("stranger")
Expand All @@ -74,8 +75,8 @@ func (s *E2ETestSuite) SetupSuite() {

// mint nfts
s.tokenIDs = make(map[string]string, 4)
for _, to := range []sdk.AccAddress{s.customer, s.operator, s.vendor, s.stranger} {
s.tokenIDs[to.String()] = s.mintNFT(s.contractID, s.vendor, to, s.nftClassID)
for _, to := range []string{s.customer, s.operator, s.vendor, s.stranger} {
s.tokenIDs[to] = s.mintNFT(s.contractID, s.vendor, to, s.nftClassID)
}

// grant all the permissions to operator
Expand Down Expand Up @@ -103,10 +104,10 @@ func (s *E2ETestSuite) TearDownSuite() {
s.network.Cleanup()
}

func (s *E2ETestSuite) createContract(creator sdk.AccAddress) string {
func (s *E2ETestSuite) createContract(creator string) string {
val := s.network.Validators[0]
args := append([]string{
creator.String(),
creator,
}, s.commonArgs...)

out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewTxCmdCreateContract(), args)
Expand All @@ -119,11 +120,11 @@ func (s *E2ETestSuite) createContract(creator sdk.AccAddress) string {
return event.ContractId
}

func (s *E2ETestSuite) createNFTClass(contractID string, operator sdk.AccAddress) string {
func (s *E2ETestSuite) createNFTClass(contractID, operator string) string {
val := s.network.Validators[0]
args := append([]string{
contractID,
operator.String(),
operator,
}, s.commonArgs...)

out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewTxCmdIssueNFT(), args)
Expand All @@ -136,12 +137,12 @@ func (s *E2ETestSuite) createNFTClass(contractID string, operator sdk.AccAddress
return event.TokenType
}

func (s *E2ETestSuite) mintNFT(contractID string, operator, to sdk.AccAddress, classID string) string {
func (s *E2ETestSuite) mintNFT(contractID, operator, to, classID string) string {
val := s.network.Validators[0]
args := append([]string{
contractID,
operator.String(),
to.String(),
operator,
to,
classID,
fmt.Sprintf("--%s=%s", cli.FlagName, "arctic fox"),
}, s.commonArgs...)
Expand All @@ -158,11 +159,11 @@ func (s *E2ETestSuite) mintNFT(contractID string, operator, to sdk.AccAddress, c
return event.Tokens[0].TokenId
}

func (s *E2ETestSuite) burnNFT(contractID string, operator sdk.AccAddress, tokenID string) collection.Coins {
func (s *E2ETestSuite) burnNFT(contractID, operator, tokenID string) collection.Coins {
val := s.network.Validators[0]
args := append([]string{
contractID,
operator.String(),
operator,
tokenID,
}, s.commonArgs...)

Expand All @@ -178,12 +179,12 @@ func (s *E2ETestSuite) burnNFT(contractID string, operator sdk.AccAddress, token
return event.Amount
}

func (s *E2ETestSuite) grant(contractID string, granter, grantee sdk.AccAddress, permission collection.Permission) {
func (s *E2ETestSuite) grant(contractID, granter, grantee string, permission collection.Permission) {
val := s.network.Validators[0]
args := append([]string{
contractID,
granter.String(),
grantee.String(),
granter,
grantee,
collection.LegacyPermission(permission).String(),
}, s.commonArgs...)

Expand All @@ -192,12 +193,12 @@ func (s *E2ETestSuite) grant(contractID string, granter, grantee sdk.AccAddress,
_ = s.getTxResp(out, 0)
}

func (s *E2ETestSuite) authorizeOperator(contractID string, holder, operator sdk.AccAddress) {
func (s *E2ETestSuite) authorizeOperator(contractID, holder, operator string) {
val := s.network.Validators[0]
args := append([]string{
contractID,
holder.String(),
operator.String(),
holder,
operator,
}, s.commonArgs...)

out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewTxCmdAuthorizeOperator(s.ac), args)
Expand All @@ -220,7 +221,7 @@ func (s *E2ETestSuite) pickEvent(events []abci.Event, event proto.Message, fn fu
}

// creates an account and send some coins to it for the future transactions.
func (s *E2ETestSuite) createAccount(uid string) sdk.AccAddress {
func (s *E2ETestSuite) createAccount(uid string) string {
val := s.network.Validators[0]
keyInfo, _, err := val.ClientCtx.Keyring.NewMnemonic(uid, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
s.Require().NoError(err)
Expand All @@ -230,7 +231,9 @@ func (s *E2ETestSuite) createAccount(uid string) sdk.AccAddress {
out, err := clitestutil.MsgSendExec(val.ClientCtx, val.Address, addr, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, cmath.NewInt(1000000))), s.ac, s.commonArgs...)
s.Require().NoError(err)
s.getTxResp(out, 0)
return addr
a, err := s.ac.BytesToString(addr)
s.Require().NoError(err)
return a
}

func (s *E2ETestSuite) getTxResp(out testutil.BufferWriter, expectedCode uint32) sdk.TxResponse {
Expand Down
Loading

0 comments on commit 92ac6e0

Please sign in to comment.