-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-1140: e2e tests for contracts (#697)
* Fix invalid clap default * Setup framework for testing the button * Test early bird play * Test marketplace contract * Test all button game variants * Run contract e2e tests on CI * Bump aleph_client version * Fix cache target list * Fix clippy warnings * Simplify scopes * Add docs * Use From/TryFrom instead of custom traits * Allow minting only in dev * Fix clippy
- Loading branch information
Showing
24 changed files
with
946 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "aleph_client" | ||
version = "1.9.0" | ||
version = "1.10.0" | ||
edition = "2021" | ||
license = "Apache 2.0" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use std::ops::Deref; | ||
|
||
use anyhow::{bail, Result}; | ||
use contract_transcode::Value; | ||
use sp_core::crypto::Ss58Codec; | ||
|
||
use crate::AccountId; | ||
|
||
/// Temporary wrapper for converting from [Value] to primitive types. | ||
/// | ||
/// ``` | ||
/// # #![feature(assert_matches)] | ||
/// # #![feature(type_ascription)] | ||
/// # use std::assert_matches::assert_matches; | ||
/// # use anyhow::{anyhow, Result}; | ||
/// # use aleph_client::{AccountId, contract::ConvertibleValue}; | ||
/// use contract_transcode::Value; | ||
/// | ||
/// assert_matches!(ConvertibleValue(Value::UInt(42)).try_into(), Ok(42)); | ||
/// assert_matches!(ConvertibleValue(Value::Bool(true)).try_into(), Ok(true)); | ||
/// assert_matches!( | ||
/// ConvertibleValue(Value::Literal("5H8cjBBzCJrAvDn9LHZpzzJi2UKvEGC9VeVYzWX5TrwRyVCA".to_string())). | ||
/// try_into(): Result<AccountId>, | ||
/// Ok(_) | ||
/// ); | ||
/// assert_matches!( | ||
/// ConvertibleValue(Value::String("not a number".to_string())).try_into(): Result<u128>, | ||
/// Err(_) | ||
/// ); | ||
/// ``` | ||
#[derive(Debug, Clone)] | ||
pub struct ConvertibleValue(pub Value); | ||
|
||
impl Deref for ConvertibleValue { | ||
type Target = Value; | ||
|
||
fn deref(&self) -> &Value { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl TryFrom<ConvertibleValue> for bool { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: ConvertibleValue) -> Result<bool, Self::Error> { | ||
match value.0 { | ||
Value::Bool(value) => Ok(value), | ||
_ => bail!("Expected {:?} to be a boolean", value.0), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<ConvertibleValue> for u128 { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: ConvertibleValue) -> Result<u128, Self::Error> { | ||
match value.0 { | ||
Value::UInt(value) => Ok(value), | ||
_ => bail!("Expected {:?} to be an integer", value.0), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<ConvertibleValue> for AccountId { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: ConvertibleValue) -> Result<AccountId, Self::Error> { | ||
match value.0 { | ||
Value::Literal(value) => Ok(AccountId::from_ss58check(&value)?), | ||
_ => bail!("Expected {:?} to be a string", value), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.