Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/marketplace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ scale-info = { version = "2.3", default-features = false, features = ["derive"],
openbrush = { tag = "3.0.0", git = "https://github.com/727-Ventures/openbrush-contracts", default-features = false, features = ["ownable", "psp34", "reentrancy_guard"] }
pallet_marketplace = { path = "../../logics", default-features = false }

[dev-dependencies]
ink_e2e = "4.0.1"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since you are updating this contract, please use the latest ink. I think it is 4.2


[lib]
path = "lib.rs"

Expand All @@ -24,6 +27,7 @@ std = [
"pallet_marketplace/std",
]
ink-as-dependency = []
e2e-tests = []

[profile.dev]
overflow-checks = false
Expand Down
43 changes: 43 additions & 0 deletions contracts/marketplace/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,47 @@ pub mod marketplace {
AccountId::from([0x2; 32])
}
}

/// end-to-end (E2E) or integration tests for marketplace.
///
/// When running these you need to make sure that you:
/// - Compile the tests with the `e2e-tests` feature flag enabled (`--features e2e-tests`)
/// - Are running a Substrate node which contains `pallet-contracts` in the background
#[cfg(all(test, feature = "e2e-tests"))]
mod e2e_tests {
/// Imports all the definitions from the outer scope so we can use them here.
use super::*;

/// A helper function used for calling contract messages.
use ink_e2e::build_message;

/// The End-to-End test `Result` type.
type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

/// We test that we can upload and instantiate the contract using its default constructor.
#[ink_e2e::test]
async fn init_works(mut client: ink_e2e::Client<C, E>) -> E2EResult<()> {
// Given
let constructor = MarketplaceRef::new(fee_recipient());

// When
let contract_account_id = client
.instantiate("marketplace", &ink_e2e::alice(), constructor, 0, None)
.await
.expect("instantiate failed")
.account_id;

// Then
let marketplace_fee = build_message::<MarketplaceRef>(contract_account_id.clone())
.call(|marketplace| marketplace.get_marketplace_fee());
let marketplace_fee_result = client.call_dry_run(&ink_e2e::alice(), &owner, 0, None).await;
assert!(matches!(marketplace_fee_result.return_value(), 100));

Ok(())
}

fn fee_recipient() -> AccountId {
AccountId::from([0x1; 32])
}
}
}
2 changes: 1 addition & 1 deletion contracts/psp34/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ std = [

"openbrush/std",
]
ink-as-dependency = []
ink-as-dependency = []
2 changes: 1 addition & 1 deletion contracts/rmrk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ std = [
"rmrk/std",
]

ink-as-dependency = []
ink-as-dependency = []