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

Bump to latest scale-encode/decode/value and fix test running #1103

Merged
merged 8 commits into from
Aug 2, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down
56 changes: 28 additions & 28 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -139,11 +139,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -173,11 +173,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -208,11 +208,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -239,11 +239,11 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -283,30 +283,30 @@ jobs:

- name: Download Substrate
run: |
curl $SUBSTRATE_URL --output substrate --location
chmod +x substrate
./substrate --version
curl $SUBSTRATE_URL --output substrate-node --location
chmod +x substrate-node
./substrate-node --version
mkdir -p ~/.local/bin
mv substrate ~/.local/bin
mv substrate-node ~/.local/bin

- name: Run subxt WASM tests
run: |
# `listen-addr` is used to configure p2p to accept websocket connections instead of TCP.
# `node-key` provides a deterministic p2p address.
substrate --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
substrate-node --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
pkill substrate
pkill substrate-node
working-directory: testing/wasm-rpc-tests

- name: Run subxt-lightclient WASM tests
run: |
# `listen-addr` is used to configure p2p to accept websocket connections instead of TCP.
# `node-key` provides a deterministic p2p address.
substrate --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
substrate-node --dev --node-key 0000000000000000000000000000000000000000000000000000000000000001 --listen-addr /ip4/0.0.0.0/tcp/30333/ws > /dev/null 2>&1 &
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
pkill substrate
pkill substrate-node
working-directory: testing/wasm-lightclient-tests

- name: Run subxt-signer WASM tests
Expand Down
35 changes: 17 additions & 18 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ proc-macro2 = "1.0.66"
quote = "1.0.31"
regex = "1.9.1"
scale-info = "2.9.0"
scale-value = "0.10.0"
scale-bits = "0.3"
scale-decode = "0.7.0"
scale-encode = "0.3.0"
scale-value = "0.12.0"
scale-bits = "0.4.0"
scale-decode = "0.9.0"
scale-encode = "0.5.0"
serde = { version = "1.0.179" }
serde_json = { version = "1.0.104" }
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
Expand Down
27 changes: 1 addition & 26 deletions subxt/src/events/events_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,25 +602,9 @@ mod tests {
/// Compare some actual [`RawEventDetails`] with a hand-constructed
/// (probably) [`TestRawEventDetails`].
pub fn assert_raw_events_match(
// Just for convenience, pass in the metadata type constructed
// by the `metadata` function above to simplify caller code.
metadata: &Metadata,
actual: EventDetails<SubstrateConfig>,
expected: TestRawEventDetails,
) {
let types = &metadata.types();

// Make sure that the bytes handed back line up with the fields handed back;
// encode the fields back into bytes and they should be equal.
let actual_fields = actual.field_values().expect("can decode field values (1)");

let mut actual_bytes = vec![];
for field in actual_fields.into_values() {
scale_value::scale::encode_as_type(&field, field.context, types, &mut actual_bytes)
.expect("should be able to encode properly");
}
assert_eq!(actual_bytes, actual.field_bytes());

let actual_fields_no_context: Vec<_> = actual
.field_values()
.expect("can decode field values (2)")
Expand Down Expand Up @@ -691,7 +675,6 @@ mod tests {

let mut event_details = events.iter();
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
phase: Phase::ApplyExtrinsic(123),
Expand Down Expand Up @@ -739,7 +722,6 @@ mod tests {
let mut event_details = events.iter();

assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 0,
Expand All @@ -752,7 +734,6 @@ mod tests {
},
);
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 1,
Expand All @@ -765,7 +746,6 @@ mod tests {
},
);
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 2,
Expand Down Expand Up @@ -809,7 +789,6 @@ mod tests {

let mut events_iter = events.iter();
assert_raw_events_match(
&metadata,
events_iter.next().unwrap().unwrap(),
TestRawEventDetails {
index: 0,
Expand All @@ -822,7 +801,6 @@ mod tests {
},
);
assert_raw_events_match(
&metadata,
events_iter.next().unwrap().unwrap(),
TestRawEventDetails {
index: 1,
Expand Down Expand Up @@ -862,7 +840,6 @@ mod tests {
// Dynamically decode:
let mut event_details = events.iter();
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 0,
Expand Down Expand Up @@ -903,7 +880,6 @@ mod tests {
// Dynamically decode:
let mut event_details = events.iter();
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 0,
Expand All @@ -912,7 +888,7 @@ mod tests {
pallet_index: 0,
variant: "A".to_string(),
variant_index: 0,
fields: vec![Value::u128(1)],
fields: vec![Value::unnamed_composite(vec![Value::u128(1)])],
},
);
assert!(event_details.next().is_none());
Expand Down Expand Up @@ -945,7 +921,6 @@ mod tests {
// Dynamically decode:
let mut event_details = events.iter();
assert_raw_events_match(
&metadata,
event_details.next().unwrap().unwrap(),
TestRawEventDetails {
index: 0,
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/tx/tx_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ where
2 => u16::decode(cursor)?.into(),
4 => u32::decode(cursor)?.into(),
8 => u64::decode(cursor)?,
_ => return Err(Error::Decode(DecodeError::custom(format!("state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)", account_nonce_bytes.len()))))
_ => return Err(Error::Decode(DecodeError::custom_string(format!("state call AccountNonceApi_account_nonce returned an unexpected number of bytes: {} (expected 2, 4 or 8)", account_nonce_bytes.len()))))
};
Ok(account_nonce)
}
Expand Down
Loading