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

Refactoring/Improve tests repository to remove boilerplate and simplify contract deployments #25

Open
srinjoyc opened this issue May 21, 2021 · 0 comments
Assignees
Labels
p-med Medium Priority

Comments

@srinjoyc
Copy link
Contributor

Currently, there is a lot of boilerplate involved in order to deploy all the contracts, get the available methods and pass this into tests. This includes things like:

export const mintKibble = async (recipient, amount) => {
	const Registry = await getRegistry();

	const name = "kibble/mint_tokens";
	const addressMap = {
		FungibleToken: Registry,
		Kibble: Registry,
	};
	const signers = [Registry];
	const args = [
		[recipient, Address],
		[amount, UFix64],
	];

	return sendTransaction({
		code,
		signers,
		args,
	});
	const code = await getTransactionCode({ name, addressMap });
...
}

The above shows how paths and contract addresses need to be mapped in order to run the transaction code.

This needs to be repeated to run any test and is quite repetitive. Since we know much of this information beforehand, we can abstract this away.

Potentially:

  • Use a generator to create a folder to host all the boilerplate code (module) so the tests can import from here and abstract a lot of it away.
  • Use a flow.test.json to define some of these settings/configs/accounts/contracts [maybe later]
@srinjoyc srinjoyc added the p-med Medium Priority label May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p-med Medium Priority
Projects
None yet
Development

No branches or pull requests

2 participants