Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing transfers to non-whitelisted smart contract #676

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

wojtek-coreum
Copy link
Collaborator

@wojtek-coreum wojtek-coreum commented Oct 17, 2023

Description

Funds might be transferred to smart contract in 3 ways:

  1. regular bank send
  2. smart contract call
  3. smart contract instantiation

In this PR, tests are added to verify that in all 3 cases transfer fails if smart contract is not whitelisted.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@wojtek-coreum wojtek-coreum requested a review from a team as a code owner October 17, 2023 11:42
@wojtek-coreum wojtek-coreum requested review from dzmitryhil, miladz68 and ysv and removed request for a team October 17, 2023 11:42
ysv
ysv previously approved these changes Oct 19, 2023
Copy link
Contributor

@ysv ysv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dzmitryhil, @miladz68, and @wojtek-coreum)


integration-tests/modules/assetft_test.go line 2387 at r1 (raw file):

// TestAssetFTSendingToNonWhitelistedSmartContractIsDenied verifies that this is not possible to send token to smart contract
// if it is not whitelisted.
func TestAssetFTSendingToNonWhitelistedSmartContractIsDenied(t *testing.T) {

nit: I would squash these 3 into a single test since they test similar functionality and this will reduce amount of code significantly

dzmitryhil
dzmitryhil previously approved these changes Oct 19, 2023
Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @miladz68 and @wojtek-coreum)

Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @wojtek-coreum)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

	}
	_, err = client.BroadcastTx(ctx, clientCtx.WithFromAddress(issuer), txf, sendMsg)
	requireT.Error(err)

assert error type.


integration-tests/modules/assetft_test.go line 2520 at r1 (raw file):

	requireT.NoError(err)
	_, err = chain.Wasm.ExecuteWASMContract(ctx, txf, issuer, contractAddr, incrementPayload, sdk.NewInt64Coin(denom, 100))
	requireT.Error(err)

assert error type


integration-tests/modules/assetft_test.go line 2583 at r1 (raw file):

		},
	)
	requireT.Error(err)

assert error type

@wojtek-coreum wojtek-coreum dismissed stale reviews from ysv and dzmitryhil via 112167b October 20, 2023 10:25
Copy link
Collaborator Author

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @dzmitryhil, @miladz68, and @ysv)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

Previously, miladz68 (milad) wrote…

assert error type.

Done.


integration-tests/modules/assetft_test.go line 2520 at r1 (raw file):

Previously, miladz68 (milad) wrote…

assert error type

Done.


integration-tests/modules/assetft_test.go line 2583 at r1 (raw file):

Previously, miladz68 (milad) wrote…

assert error type

Done.

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @miladz68 and @ysv)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

Done.

You should be able to assert ErrWhitelistedLimitExceeded type not string (same in other places).

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @miladz68)

Copy link
Collaborator Author

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @miladz68)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

You should be able to assert ErrWhitelistedLimitExceeded type not string (same in other places).

no, because errors are returned from simulation, and those errors are not typed

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @miladz68)

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @miladz68)

Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dzmitryhil)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

no, because errors are returned from simulation, and those errors are not typed

but it is not a simultaion !

Copy link
Collaborator Author

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @miladz68)


integration-tests/modules/assetft_test.go line 2453 at r1 (raw file):

Previously, miladz68 (milad) wrote…

but it is not a simultaion !

yea, I rewrote a test a bit to turn off simulation for this transaction and now error type is asserted

Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @wojtek-coreum)

@wojtek-coreum wojtek-coreum merged commit f3af2f2 into master Oct 25, 2023
7 checks passed
@wojtek-coreum wojtek-coreum deleted the wojtek/contract-whitelisting branch October 25, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants