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

chore: use four threads for tests and features refactoring #7

Merged
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: 2 additions & 2 deletions .env/custom_example.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#
# Simply remove the prefixed `#` to enable them.

# The cargo features should either be `mainnet`, `testnet` or something extra in order to make use
# The cargo features should either be `mainnet`, `default` or something extra in order to make use
# of your own custom features.
#CARGO_FEATURES_BUILD = "mainnet"

# The cargo test features are used to build a test environment version of the fungible-token WASM and test
# library. Either use `mainnet-test`, `testnet-test` or something extra in order to make use of your
# library. Either use something extra in order to make use of your
# own custom features.
#CARGO_FEATURES_BUILD_TEST = "mainnet,integration-test"

Expand Down
2 changes: 1 addition & 1 deletion .env/local.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CARGO_FEATURES_BUILD = "testnet"
CARGO_FEATURES_BUILD = "mainnet"
RUSTC_FLAGS_BUILD = "-C link-arg=-s"
NEAR_EVM_ACCOUNT = "aurora.test.near"
WASM_FILE = "aurora-eth-connector-local.wasm"
Expand Down
2 changes: 1 addition & 1 deletion .env/mainnet.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CARGO_FEATURES_BUILD = "mainnet"
CARGO_FEATURES_BUILD_MIGRATION = "mainnet,migration"
CARGO_FEATURES_BUILD_TEST = "mainnet,integration-test,migration"
CARGO_FEATURES_TEST = "mainnet-test"
CARGO_FEATURES_TEST = ""
RUSTC_FLAGS_BUILD = "-C link-arg=-s"
NEAR_EVM_ACCOUNT = "aurora"
WASM_FILE = "aurora-eth-connector-mainnet.wasm"
Expand Down
8 changes: 4 additions & 4 deletions .env/testnet.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CARGO_FEATURES_BUILD = "testnet"
CARGO_FEATURES_BUILD_MIGRATION = "testnet,migration"
CARGO_FEATURES_BUILD_TEST = "testnet,integration-test,migration"
CARGO_FEATURES_TEST = "testnet-test"
CARGO_FEATURES_BUILD = "mainnet"
CARGO_FEATURES_BUILD_MIGRATION = "mainnet,migration"
CARGO_FEATURES_BUILD_TEST = "mainnet,integration-test,migration"
CARGO_FEATURES_TEST = ""
RUSTC_FLAGS_BUILD = "-C link-arg=-s"
NEAR_EVM_ACCOUNT = "aurora"
WASM_FILE = "aurora-eth-connector-testnet.wasm"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
name: Tests
jobs:
test:
name: Test suite (mainnet, testnet)
name: Test suite (mainnet)
runs-on: [self-hosted, heavy]
steps:
- name: Clone the repository
Expand All @@ -18,10 +18,6 @@ jobs:
run: cargo make --profile mainnet build-test
- name: Test mainnet
run: cargo make --profile mainnet test-workspace
- name: Build testnet test WASM
run: cargo make --profile testnet build-test
- name: Test testnet
run: cargo make --profile testnet test-workspace

env:
CARGO_TERM_COLOR: always
Expand Down
1 change: 1 addition & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ args = [
"--features",
"${CARGO_FEATURES_TEST}",
"--",
"--test-threads=4",
"--nocapture"
]

Expand Down
3 changes: 0 additions & 3 deletions eth-connector-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ rlp = { version = "0.5.0", default-features = false }
aurora-engine-migration-tool = { git = "https://github.com/aurora-is-near/aurora-engine-migration-tool.git" }

[features]
mainnet-test = []
testnet-test = []

24 changes: 10 additions & 14 deletions eth-connector-tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,16 @@ impl TestContract {

let worker = workspaces::sandbox()
.await
.map_err(|err| format!("Failed init sandbox: {:?}", err))
.unwrap();

.map_err(|err| anyhow::anyhow!("Failed init sandbox: {:?}", err))?;
let testnet = workspaces::testnet()
.await
.map_err(|err| format!("Failed init testnet: {:?}", err))
.unwrap();
.map_err(|err| anyhow::anyhow!("Failed init testnet: {:?}", err))?;
let registrar: AccountId = "registrar".parse()?;
let registrar = worker
.import_contract(&registrar, &testnet)
.transact()
.await?;
Self::waiting_account_creation(&worker, registrar.id()).await;
Self::waiting_account_creation(&worker, registrar.id()).await?;

let sk = SecretKey::from_seed(KeyType::ED25519, "registrar");

Expand Down Expand Up @@ -153,23 +150,22 @@ impl TestContract {
async fn waiting_account_creation<T: NetworkClient + ?Sized>(
worker: &Worker<T>,
account_id: &AccountId,
) {
) -> anyhow::Result<()> {
let timer = std::time::Instant::now();
// Try get account within 20 secs
for _ in 0..40 {
// Try to get account within 30 secs
for _ in 0..60 {
if worker.view_account(account_id).await.is_err() {
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
} else {
// Just exit from function
return;
return Ok(());
}
}
// Immediately panic, because account not created
panic!(

anyhow::bail!(
"Account `{}` was not created in {:?} sec",
account_id,
timer.elapsed()
);
)
}

pub async fn deposit_with_proof(&self, proof: &Proof) -> anyhow::Result<ExecutionFinalResult> {
Expand Down
3 changes: 2 additions & 1 deletion eth-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ rand = "0.8.5"
[features]
log = []
integration-test = ["log"]
# Currently feature `mainnet` used only for
# Makefile.toml profiles to indicate basic features
mainnet = ["log"]
testnet = ["log"]
migration = ["log"]