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

refactor: contract integration test should streamline the error for better testing #119

Closed
Tracked by #132
chungquantin opened this issue Jul 23, 2024 · 2 comments
Closed
Tracked by #132

Comments

@chungquantin
Copy link
Collaborator

chungquantin commented Jul 23, 2024

cc: @Daanvdplas

fn decoded<T: Decode>(result: ExecReturnValue) -> T {
	match <T>::decode(&mut &result.data[2..]) {
		Ok(value) => value,
		Err(_) => panic!("\nTest failed by trying to decode `{:?}` into `T`\n", result),
	}
}

At the moment, any method failed will end up at line 13:39 which is inside the decoded method. This is very hard to debug. My recommendation is to refactor the decoded method to return Result<T> so it can streamline the error back to the main function. Something like:

fn decoded<T: Decode>(result: ExecReturnValue) -> Result<T> {
	<T>::decode(&mut &result.data[2..]).map_err("\nTest failed by trying to decode `{:?}` into `T`\n", result)
}
@Daanvdplas
Copy link
Collaborator

Yes this was something that could be improved, great suggestion!

@Daanvdplas Daanvdplas changed the title refractor: contract integration test should streamline the error for better testing refactor: contract integration test should streamline the error for better testing Jul 26, 2024
@Daanvdplas
Copy link
Collaborator

Fixed by #130

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

No branches or pull requests

2 participants