Skip to content

Commit 31994fa

Browse files
authored
Merge pull request #16 from enigmampc/reuven-integration-tests
added the infrastructure for shell based integration tests
2 parents 49e1484 + 93f2332 commit 31994fa

File tree

14 files changed

+1878
-6
lines changed

14 files changed

+1878
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Build results
22
/target
3+
contract.wasm
4+
contract.wasm.gz
35

46
# Binaries
57
*.wasm

Makefile

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,82 @@
1-
all:
1+
SECRETCLI = docker exec -it secretdev /usr/bin/secretcli
2+
3+
.PHONY: all
4+
all: clippy test
5+
6+
.PHONY: check
7+
check:
8+
cargo check
9+
10+
.PHONY: check-receiver
11+
check-receiver:
12+
$(MAKE) -C tests/example-receiver check
13+
14+
.PHONY: clippy
15+
clippy:
16+
cargo clippy
17+
18+
.PHONY: clippy-receiver
19+
clippy-receiver:
20+
$(MAKE) -C tests/example-receiver clippy
21+
22+
.PHONY: test
23+
test: unit-test unit-test-receiver integration-test
24+
25+
.PHONY: unit-test
26+
unit-test:
27+
cargo test
28+
29+
.PHONY: unit-test-receiver
30+
unit-test-receiver:
31+
$(MAKE) -C tests/example-receiver unit-test
32+
33+
.PHONY: integration-test
34+
integration-test: compile-optimized compile-optimized-receiver
35+
tests/integration.sh
36+
37+
compile-optimized-receiver:
38+
$(MAKE) -C tests/example-receiver compile-optimized
39+
40+
.PHONY: list-code
41+
list-code:
42+
$(SECRETCLI) query compute list-code
43+
44+
.PHONY: compile _compile
45+
compile: _compile contract.wasm.gz
46+
_compile:
47+
cargo build --target wasm32-unknown-unknown --locked
48+
cp ./target/wasm32-unknown-unknown/debug/*.wasm ./contract.wasm
49+
50+
.PHONY: compile-optimized _compile-optimized
51+
compile-optimized: _compile-optimized contract.wasm.gz
52+
_compile-optimized:
253
RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown --locked
3-
## The following line is not necessary, may work only on linux (extra size optimization)
54+
@# The following line is not necessary, may work only on linux (extra size optimization)
455
wasm-opt -Os ./target/wasm32-unknown-unknown/release/*.wasm -o ./contract.wasm
5-
cat ./contract.wasm | gzip -9 > ./contract.wasm.gz
656

57+
.PHONY: compile-optimized-reproducible
58+
compile-optimized-reproducible:
59+
docker run --rm -v "$$(pwd)":/contract \
60+
--mount type=volume,source="$$(basename "$$(pwd)")_cache",target=/code/target \
61+
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
62+
enigmampc/secret-contract-optimizer:1.0.3
63+
64+
contract.wasm.gz: contract.wasm
65+
cat ./contract.wasm | gzip -9 > ./contract.wasm.gz
66+
67+
.PHONY: start-server
68+
start-server: # CTRL+C to stop
69+
docker run -it --rm \
70+
-p 26657:26657 -p 26656:26656 -p 1317:1317 \
71+
-v $$(pwd):/root/code \
72+
--name secretdev enigmampc/secret-network-sw-dev:v1.0.2
73+
74+
.PHONY: schema
75+
schema:
76+
cargo run --example schema
77+
78+
.PHONY: clean
779
clean:
880
cargo clean
9-
-rm -f ./contract.wasm ./contract.wasm.gz
81+
rm -f ./contract.wasm ./contract.wasm.gz
82+
$(MAKE) -C tests/example-receiver clean

src/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ mod tests {
10741074
use crate::msg::ResponseStatus;
10751075
use crate::msg::{InitConfig, InitialBalance};
10761076
use cosmwasm_std::testing::*;
1077-
use cosmwasm_std::{from_binary, BlockInfo, ContractInfo, MessageInfo, WasmMsg};
1077+
use cosmwasm_std::{from_binary, BlockInfo, ContractInfo, MessageInfo, QueryResponse, WasmMsg};
10781078
use std::any::Any;
10791079

10801080
// Helper functions
@@ -1130,7 +1130,7 @@ mod tests {
11301130
match error {
11311131
Ok(response) => {
11321132
let bin_err = (&response as &dyn Any)
1133-
.downcast_ref::<Binary>()
1133+
.downcast_ref::<QueryResponse>()
11341134
.expect("An error was expected, but no error could be extracted");
11351135
match from_binary(bin_err).unwrap() {
11361136
QueryAnswer::ViewingKeyError { msg } => msg,

tests/example-receiver/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Build results
2+
/target
3+
contract.wasm
4+
contract.wasm.gz
5+
6+
# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327)
7+
.cargo-ok
8+
9+
# Text file backups
10+
**/*.rs.bk
11+
12+
# macOS
13+
.DS_Store
14+
15+
# IDEs
16+
*.iml
17+
.idea

tests/example-receiver/Cargo.lock

Lines changed: 263 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)