-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from provenance-io/kwtalley/provwasm-test-tub…
…e-integration-tests Kwtalley/provwasm test tube integration tests
- Loading branch information
Showing
12 changed files
with
521 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ jobs: | |
run: | | ||
cd ./contracts/tutorial | ||
make all | ||
- name: Integration test | ||
run: | | ||
cargo test --test tutorial | ||
- name: Smart Contract Test setup | ||
uses: provenance-io/[email protected] | ||
with: | ||
|
@@ -52,6 +55,9 @@ jobs: | |
run: | | ||
cd ./contracts/attrs | ||
make all | ||
- name: Integration test | ||
run: | | ||
cargo test --test attrs | ||
- name: Smart Contract Test setup | ||
uses: provenance-io/[email protected] | ||
with: | ||
|
@@ -73,6 +79,9 @@ jobs: | |
run: | | ||
cd ./contracts/marker | ||
make all | ||
- name: Integration test | ||
run: | | ||
cargo test --test marker | ||
- name: Provenance Test | ||
uses: provenance-io/[email protected] | ||
with: | ||
|
@@ -115,6 +124,9 @@ jobs: | |
run: | | ||
cd ./contracts/name | ||
make all | ||
- name: Integration test | ||
run: | | ||
cargo test --test name | ||
- name: Smart Contract Test setup | ||
uses: provenance-io/[email protected] | ||
with: | ||
|
@@ -157,6 +169,9 @@ jobs: | |
run: | | ||
cd ./contracts/trigger | ||
make all | ||
- name: Integration test | ||
run: | | ||
cargo test --test trigger | ||
- name: Smart Contract Test setup | ||
uses: provenance-io/[email protected] | ||
with: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ license = { workspace = true } | |
authors = ["Phil Story <[email protected]>", "Ken Talley <[email protected]"] | ||
|
||
exclude = [ | ||
"marker.wasm", | ||
"checksums.txt", | ||
"marker.wasm", | ||
"checksums.txt", | ||
] | ||
|
||
[lib] | ||
|
@@ -23,10 +23,10 @@ cosmwasm-schema = { workspace = true } | |
cosmwasm-std = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
provwasm-std = { workspace = true } | ||
schemars = {workspace = true} | ||
schemars = { workspace = true } | ||
serde = { workspace = true, default-features = false, features = ["derive"] } | ||
thiserror = { workspace = true } | ||
|
||
[dev-dependencies] | ||
prost = {workspace = true, default-features = false} | ||
prost = { workspace = true, default-features = false } | ||
provwasm-mocks = { workspace = true } |
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,25 @@ | ||
[package] | ||
name = "integration" | ||
version = { workspace = true } | ||
repository = { workspace = true } | ||
edition = { workspace = true } | ||
license = { workspace = true } | ||
authors = ["Ken Talley <[email protected]"] | ||
|
||
[features] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = [] | ||
|
||
[dependencies] | ||
cosmwasm-std = { workspace = true } | ||
attrs = { version = "2.2.0", path = "../contracts/attrs" } | ||
marker = { version = "2.2.0", path = "../contracts/marker" } | ||
name = { version = "2.2.0", path = "../contracts/name" } | ||
trigger = { version = "2.2.0", path = "../contracts/trigger" } | ||
provwasm-tutorial = { version = "2.2.0", path = "../contracts/tutorial" } | ||
provwasm-std = { workspace = true } | ||
|
||
[dev-dependencies] | ||
prost = { workspace = true, default-features = false } | ||
provwasm-mocks = { workspace = true } | ||
provwasm-test-tube = { workspace = true } |
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,33 @@ | ||
.PHONY: all | ||
all: fmt test lint schema | ||
|
||
UNAME_M := $(shell uname -m) | ||
|
||
.PHONY: fmt | ||
fmt: | ||
@cargo fmt --all -- --check | ||
|
||
.PHONY: build | ||
build: | ||
@cargo build | ||
|
||
.PHONY: test | ||
test: | ||
@cargo test | ||
|
||
.PHONY: lint | ||
lint: | ||
@cargo clippy | ||
|
||
.PHONY: schema | ||
schema: | ||
@cargo schema | ||
|
||
.PHONY: clean | ||
clean: | ||
@cargo clean | ||
@cargo clean --target-dir artifacts | ||
|
||
.PHONY: check | ||
check: | ||
@cargo check |
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,103 @@ | ||
use cosmwasm_std::Coin; | ||
use provwasm_test_tube::wasm::Wasm; | ||
use provwasm_test_tube::{Account, Module, ProvwasmTestApp, RunnerError}; | ||
|
||
use attrs::msg::{ExecuteMsg, InitMsg, Label, LabelNameResponse, LabelsResponse, QueryMsg}; | ||
|
||
#[test] | ||
fn create_update_delete_attr() -> Result<(), RunnerError> { | ||
let app = ProvwasmTestApp::default(); | ||
let accs = app.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?; | ||
let admin = &accs[0]; | ||
|
||
let wasm = Wasm::new(&app); | ||
let wasm_byte_code = std::fs::read("../contracts/attrs/artifacts/attrs.wasm").unwrap(); | ||
let store_res = wasm.store_code(&wasm_byte_code, None, admin); | ||
let code_id = store_res?.data.code_id; | ||
assert_eq!(code_id, 1); | ||
|
||
// let init_admins = vec![admin.address()]; | ||
let contract_addr = wasm | ||
.instantiate( | ||
code_id, | ||
&InitMsg { | ||
name: "attrs-test.sc.pb".to_string(), | ||
}, | ||
Some(&admin.address()), | ||
None, | ||
&[], | ||
admin, | ||
)? | ||
.data | ||
.address; | ||
|
||
wasm.execute::<ExecuteMsg>(&contract_addr, &ExecuteMsg::BindLabelName {}, &[], admin)?; | ||
let label_name_response = | ||
wasm.query::<QueryMsg, LabelNameResponse>(&contract_addr, &QueryMsg::GetLabelName {})?; | ||
assert_eq!(label_name_response.name, "label.attrs-test.sc.pb"); | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::AddLabel { | ||
text: "hello".to_string(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::AddLabel { | ||
text: "wasm".to_string(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
let label_name_response = | ||
wasm.query::<QueryMsg, LabelsResponse>(&contract_addr, &QueryMsg::GetLabels {})?; | ||
assert!(label_name_response.labels.contains(&Label { | ||
text: "hello".to_string() | ||
})); | ||
assert!(label_name_response.labels.contains(&Label { | ||
text: "wasm".to_string() | ||
})); | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::UpdateLabel { | ||
original_text: "hello".to_string(), | ||
update_text: "goodbye".to_string(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
let label_name_response = | ||
wasm.query::<QueryMsg, LabelsResponse>(&contract_addr, &QueryMsg::GetLabels {})?; | ||
assert!(label_name_response.labels.contains(&Label { | ||
text: "goodbye".to_string() | ||
})); | ||
assert!(label_name_response.labels.contains(&Label { | ||
text: "wasm".to_string() | ||
})); | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::DeleteDistinctLabel { | ||
text: "wasm".to_string(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
let label_name_response = | ||
wasm.query::<QueryMsg, LabelsResponse>(&contract_addr, &QueryMsg::GetLabels {})?; | ||
assert!(label_name_response.labels.contains(&Label { | ||
text: "goodbye".to_string() | ||
})); | ||
|
||
wasm.execute::<ExecuteMsg>(&contract_addr, &ExecuteMsg::DeleteLabels {}, &[], admin)?; | ||
|
||
let label_name_response = | ||
wasm.query::<QueryMsg, LabelsResponse>(&contract_addr, &QueryMsg::GetLabels {})?; | ||
assert!(label_name_response.labels.is_empty()); | ||
|
||
Ok(()) | ||
} |
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,93 @@ | ||
use cosmwasm_std::{Coin, Uint128}; | ||
use provwasm_test_tube::wasm::Wasm; | ||
use provwasm_test_tube::{Account, Module, ProvwasmTestApp, RunnerError}; | ||
|
||
use marker::msg::{ExecuteMsg, InitMsg, QueryMsg}; | ||
use marker::types::Marker; | ||
|
||
#[test] | ||
fn create_and_withdraw() -> Result<(), RunnerError> { | ||
let app = ProvwasmTestApp::default(); | ||
let accs = app.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?; | ||
let admin = &accs[0]; | ||
|
||
let wasm = Wasm::new(&app); | ||
let wasm_byte_code = std::fs::read("../contracts/marker/artifacts/marker.wasm").unwrap(); | ||
let store_res = wasm.store_code(&wasm_byte_code, None, admin); | ||
let code_id = store_res?.data.code_id; | ||
assert_eq!(code_id, 1); | ||
|
||
// let init_admins = vec![admin.address()]; | ||
let contract_addr = wasm | ||
.instantiate( | ||
code_id, | ||
&InitMsg { | ||
name: "marker-test.sc.pb".to_string(), | ||
}, | ||
Some(&admin.address()), | ||
None, | ||
&[], | ||
admin, | ||
)? | ||
.data | ||
.address; | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::Create { | ||
supply: Uint128::new(100), | ||
denom: "spy".into(), | ||
allow_forced_transfer: false, | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::GrantAccess { | ||
denom: "spy".into(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::Finalize { | ||
denom: "spy".into(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::Activate { | ||
denom: "spy".into(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
|
||
wasm.execute::<ExecuteMsg>( | ||
&contract_addr, | ||
&ExecuteMsg::Withdraw { | ||
amount: Uint128::new(20), | ||
denom: "spy".into(), | ||
}, | ||
&[], | ||
admin, | ||
)?; | ||
|
||
let marker = wasm.query::<QueryMsg, Marker>( | ||
&contract_addr, | ||
&QueryMsg::GetByDenom { | ||
denom: "spy".into(), | ||
}, | ||
)?; | ||
|
||
assert_eq!(marker.marker_account.denom, "spy"); | ||
|
||
Ok(()) | ||
} |
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,5 @@ | ||
mod attrs; | ||
mod marker; | ||
mod name; | ||
mod trigger; | ||
mod tutorial; |
Oops, something went wrong.