Skip to content

Commit

Permalink
dockertest 0.5, correct errors from prior update commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Sep 6, 2024
1 parent 0d5756f commit c1a9256
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 49 deletions.
65 changes: 44 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ panic = "unwind"
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }

# Needed due to dockertest's usage of `Rc`s when we need `Arc`s
dockertest = { git = "https://github.com/orcalabs/dockertest-rs", rev = "4dd6ae24738aa6dc5c89444cc822ea4745517493" }

parking_lot_core = { path = "patches/parking_lot_core" }
parking_lot = { path = "patches/parking_lot" }
# wasmtime pulls in an old version for this
Expand All @@ -161,6 +158,9 @@ matches = { path = "patches/matches" }
option-ext = { path = "patches/option-ext" }
directories-next = { path = "patches/directories-next" }

# https://github.com/alloy-rs/core/issues/717
alloy-sol-type-parser = { git = "https://github.com/alloy-rs/core", rev = "446b9d2fbce12b88456152170709a3eaac929af0" }

[workspace.lints.clippy]
unwrap_or_default = "allow"
borrow_as_ptr = "deny"
Expand Down
3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ignore = [
"RUSTSEC-2020-0168", # mach is unmaintained
"RUSTSEC-2021-0139", # https://github.com/serai-dex/serai/228
"RUSTSEC-2022-0061", # https://github.com/serai-dex/serai/227
"RUSTSEC-2024-0370", # proc-macro-error is unmaintained
]

[licenses]
Expand Down Expand Up @@ -101,5 +102,5 @@ allow-git = [
"https://github.com/rust-lang-nursery/lazy-static.rs",
"https://github.com/serai-dex/substrate-bip39",
"https://github.com/serai-dex/substrate",
"https://github.com/orcalabs/dockertest-rs",
"https://github.com/alloy-rs/core",
]
4 changes: 2 additions & 2 deletions networks/ethereum/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use k256::{Scalar, ProjectivePoint};
use frost::{curve::Secp256k1, Participant, ThresholdKeys, tests::key_gen as frost_key_gen};

use alloy_core::{
primitives::{Address, U256, Bytes, TxKind},
primitives::{Address, U256, Bytes, Signature, TxKind},
hex::FromHex,
};
use alloy_consensus::{SignableTransaction, TxLegacy};
Expand Down Expand Up @@ -69,7 +69,7 @@ pub async fn send(
);

let mut bytes = vec![];
tx.encode_with_signature_fields(&sig.into(), &mut bytes);
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);
let pending_tx = provider.send_raw_transaction(&bytes).await.ok()?;
pending_tx.get_receipt().await.ok()
}
Expand Down
1 change: 0 additions & 1 deletion networks/ethereum/src/tests/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ async fn latest_block_hash(client: &RootProvider<SimpleRequest>) -> [u8; 32] {
.unwrap()
.header
.hash
.unwrap()
.0
}

Expand Down
2 changes: 1 addition & 1 deletion processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sp-application-crypto = { git = "https://github.com/serai-dex/substrate", defaul

ethereum-serai = { path = "../networks/ethereum", default-features = false, features = ["tests"] }

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../tests/docker" }

[features]
Expand Down
11 changes: 4 additions & 7 deletions processor/src/networks/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,7 @@ impl<D: Db> Network for Ethereum<D> {
.map_err(|_| NetworkError::ConnectionError)?
.ok_or(NetworkError::ConnectionError)?
.header
.number
.unwrap();
.number;
// Error if there hasn't been a full epoch yet
if actual_number < 32 {
Err(NetworkError::ConnectionError)?
Expand Down Expand Up @@ -467,7 +466,6 @@ impl<D: Db> Network for Ethereum<D> {
.ok_or(NetworkError::ConnectionError)?
.header
.hash
.unwrap()
.into()
};

Expand All @@ -480,7 +478,7 @@ impl<D: Db> Network for Ethereum<D> {
.ok_or(NetworkError::ConnectionError)?
.header;

let end_hash = end_header.hash.unwrap().into();
let end_hash = end_header.hash.into();
let time = end_header.timestamp;

Ok(Epoch { prior_end_hash, start: start.try_into().unwrap(), end_hash, time })
Expand Down Expand Up @@ -813,7 +811,6 @@ impl<D: Db> Network for Ethereum<D> {
.unwrap()
.header
.number
.unwrap()
.try_into()
.unwrap()
}
Expand Down Expand Up @@ -921,13 +918,13 @@ impl<D: Db> Network for Ethereum<D> {
.into(),
};

use ethereum_serai::alloy::consensus::SignableTransaction;
use ethereum_serai::alloy::{primitives::Signature, consensus::SignableTransaction};
let sig = k256::ecdsa::SigningKey::from(k256::elliptic_curve::NonZeroScalar::new(key).unwrap())
.sign_prehash_recoverable(tx.signature_hash().as_ref())
.unwrap();

let mut bytes = vec![];
tx.encode_with_signature_fields(&sig.into(), &mut bytes);
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);
let pending_tx = self.provider.send_raw_transaction(&bytes).await.ok().unwrap();

// Mine an epoch containing this TX
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ schnorrkel = { path = "../../crypto/schnorrkel", package = "frost-schnorrkel" }

tokio = "1"

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../../tests/docker" }

[features]
Expand Down
2 changes: 1 addition & 1 deletion tests/coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ borsh = { version = "1", features = ["de_strict_order"] }

tokio = { version = "1", features = ["time"] }

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../docker" }
serai-message-queue-tests = { path = "../message-queue" }
2 changes: 1 addition & 1 deletion tests/full-stack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ serai-client = { path = "../../substrate/client", features = ["serai"] }

tokio = { version = "1", features = ["time"] }

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../docker" }
serai-message-queue-tests = { path = "../message-queue" }
serai-processor-tests = { path = "../processor" }
Expand Down
2 changes: 1 addition & 1 deletion tests/message-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ serai-primitives = { path = "../../substrate/primitives" }
serai-message-queue = { path = "../../message-queue" }

tokio = { version = "1", features = ["time"] }
dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../docker" }
2 changes: 1 addition & 1 deletion tests/processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ tokio = { version = "1", features = ["time"] }

processor = { package = "serai-processor", path = "../../processor", features = ["bitcoin", "ethereum", "monero"] }

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../docker" }
serai-message-queue-tests = { path = "../message-queue" }
6 changes: 2 additions & 4 deletions tests/processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ impl Coordinator {
.unwrap()
.unwrap()
.header
.number
.unwrap();
.number;
// We mine 96 blocks to mine one epoch, then cause its finalization
provider.raw_request::<_, ()>("anvil_mine".into(), [96]).await.unwrap();
let end_of_epoch = start + 31;
Expand All @@ -389,8 +388,7 @@ impl Coordinator {
.unwrap()
.unwrap()
.header
.hash
.unwrap();
.hash;

let state = provider
.raw_request::<_, String>("anvil_dumpState".into(), ())
Expand Down
6 changes: 3 additions & 3 deletions tests/processor/src/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl Wallet {
use std::sync::Arc;
use ethereum_serai::{
alloy::{
primitives::{U256, TxKind},
primitives::{U256, Signature, TxKind},
sol_types::SolCall,
simple_request_transport::SimpleRequest,
consensus::{TxLegacy, SignableTransaction},
Expand Down Expand Up @@ -355,7 +355,7 @@ impl Wallet {
.unwrap();

let mut bytes = vec![];
tx.encode_with_signature_fields(&sig, &mut bytes);
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);
let _ = provider.send_raw_transaction(&bytes).await.unwrap();

provider.raw_request::<_, ()>("anvil_mine".into(), [96]).await.unwrap();
Expand Down Expand Up @@ -395,7 +395,7 @@ impl Wallet {
.unwrap();

let mut bytes = vec![];
tx.encode_with_signature_fields(&sig.into(), &mut bytes);
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);

// We drop the bottom 10 decimals
(
Expand Down
2 changes: 1 addition & 1 deletion tests/reproducible-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ workspace = true
rand_core = "0.6"
hex = "0.4"

dockertest = "0.4"
dockertest = "0.5"
serai-docker-tests = { path = "../docker" }

tokio = { version = "1", features = ["time"] }

0 comments on commit c1a9256

Please sign in to comment.