Skip to content

Commit

Permalink
Prepare smart contract testing library for release (#414)
Browse files Browse the repository at this point in the history
* Bump Rust SDK and therefore also MSRV to 1.73

* Use released version of testing library in templates
  • Loading branch information
limemloh authored Mar 26, 2024
1 parent e3e75e3 commit d874117
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter-testing-lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:

env:
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu
RUST_CLIPPY: 1.72
RUST_CLIPPY: 1.73

jobs:
"lint_fmt":
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ name: Clippy & fmt

env:
RUST_FMT: nightly-2023-04-01
RUST_VERSION: "1.66"
RUST_VERSION_TESTING_LIBRARY: "1.72"
RUST_VERSION: "1.73"
RUST_VERSION_TESTING_LIBRARY: "1.73"
CARGO_CONCORDIUM_VERSION: "3.2.0"

jobs:
Expand Down Expand Up @@ -351,7 +351,7 @@ jobs:
sed -i "s/root/Concordium <[email protected]>/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/{version = \"10.0\", default-features = false}/{path = \"..\/..\/concordium-std\", default-features = false}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/{version = \"6.1\", default-features = false}/{path = \"..\/..\/concordium-cis2\", default-features = false}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/concordium-smart-contract-testing = \"4.0\"/concordium-smart-contract-testing = {path = \"..\/..\/contract-testing\"}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/concordium-smart-contract-testing = \"4.2\"/concordium-smart-contract-testing = {path = \"..\/..\/contract-testing\"}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml examples/cis2-nft/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/src/lib.rs examples/cis2-nft/src/lib.rs
diff ${{ runner.temp }}/$PROJECT_NAME/tests/tests.rs examples/cis2-nft/tests/tests.rs
Expand Down Expand Up @@ -399,7 +399,7 @@ jobs:
sed -i "s/root/Concordium <[email protected]>/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/version = \"10.0\", default-features = false/path = \"..\/..\/concordium-std\", version = \"10.0\", default-features = false/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/version = \"6.1\", default-features = false/path = \"..\/..\/concordium-cis2\", version = \"6.1\", default-features = false/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/concordium-smart-contract-testing = \"4.0\"/concordium-smart-contract-testing = {path = \"..\/..\/contract-testing\"}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
sed -i "s/concordium-smart-contract-testing = \"4.2\"/concordium-smart-contract-testing = {path = \"..\/..\/contract-testing\"}/g" ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/Cargo.toml examples/credential-registry/Cargo.toml
diff ${{ runner.temp }}/$PROJECT_NAME/src/lib.rs examples/credential-registry/src/lib.rs
diff ${{ runner.temp }}/$PROJECT_NAME/tests/tests.rs examples/credential-registry/tests/tests.rs
Expand Down
12 changes: 4 additions & 8 deletions concordium-std/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ where
StateApi: HasStateApi,
{
/// Ensures a value is in the entry by inserting the default value if empty.
#[allow(clippy::unwrap_or_default)]
pub fn or_default(self) -> OccupiedEntry<'a, K, V, StateApi> {
self.or_insert_with(Default::default)
}
Expand Down Expand Up @@ -2195,9 +2196,8 @@ fn query_exchange_rates_worker() -> ExchangeRates {
/// two extern hosts below.
fn query_account_public_keys_worker(address: AccountAddress) -> QueryAccountPublicKeysResult {
let data: &[u8] = address.as_ref();
let response = unsafe {
prims::invoke(INVOKE_QUERY_ACCOUNT_PUBLIC_KEYS_TAG, data.as_ptr() as *const u8, 32)
};
let response =
unsafe { prims::invoke(INVOKE_QUERY_ACCOUNT_PUBLIC_KEYS_TAG, data.as_ptr(), 32) };
let mut return_value = parse_query_account_public_keys_response_code(response)?;
Ok(crate::AccountPublicKeys::deserial(&mut return_value).unwrap_abort())
}
Expand All @@ -2213,11 +2213,7 @@ fn check_account_signature_worker(
signatures.serial(&mut buffer).unwrap_abort();

let response = unsafe {
prims::invoke(
INVOKE_CHECK_ACCOUNT_SIGNATURE_TAG,
buffer.as_ptr() as *const u8,
buffer.len() as u32,
)
prims::invoke(INVOKE_CHECK_ACCOUNT_SIGNATURE_TAG, buffer.as_ptr(), buffer.len() as u32)
};
// Be explicit that the buffer must survive up to here.
drop(buffer);
Expand Down
4 changes: 2 additions & 2 deletions concordium-std/tests/state/map-multiple-entries.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `map` as mutable more than once at a time
--> tests/state/map-multiple-entries.rs:12:14
|
11 | let e1 = map.entry(0u8);
| -------------- first mutable borrow occurs here
| --- first mutable borrow occurs here
12 | let e2 = map.entry(1u8);
| ^^^^^^^^^^^^^^ second mutable borrow occurs here
| ^^^ second mutable borrow occurs here
13 | // Use them, so we are certain that their lifetimes overlap.
14 | e1.or_insert(1);
| -- first borrow later used here
4 changes: 2 additions & 2 deletions concordium-std/tests/state/map-multiple-state-ref-mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `map` as mutable more than once at a time
--> tests/state/map-multiple-state-ref-mut.rs:14:14
|
13 | let e1 = map.get_mut(&0u8).unwrap();
| ----------------- first mutable borrow occurs here
| --- first mutable borrow occurs here
14 | let e2 = map.get_mut(&1u8).unwrap();
| ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| ^^^ second mutable borrow occurs here
15 | // Use them, so we are certain that their lifetimes overlap.
16 | assert_eq!(*e1, *e2);
| -- first borrow later used here
4 changes: 3 additions & 1 deletion contract-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Unreleased changes

## 4.2.0

- Add support for querying the module reference and contract name of an instance.
This functionality is only available on-chain from protocol version 7.
- Bump minimum supported Rust version (MSRV) to `1.72`.
- Bump minimum supported Rust version (MSRV) to `1.73`.

## 4.1.0

Expand Down
2 changes: 1 addition & 1 deletion contract-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "concordium-smart-contract-testing"
version = "4.2.0"
edition = "2021"
rust-version = "1.72"
rust-version = "1.73"
license = "MPL-2.0"
readme = "README.md"
description = "A companion crate to `concordium-std` that supports off-chain end-to-end testing of smart contracts."
Expand Down
2 changes: 1 addition & 1 deletion templates/cis2-nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concordium-std = {version = "10.0", default-features = false}
concordium-cis2 = {version = "6.1", default-features = false}

[dev-dependencies]
concordium-smart-contract-testing = "4.0"
concordium-smart-contract-testing = "4.2"

[lib]
crate-type=["cdylib", "rlib"]
Expand Down
2 changes: 1 addition & 1 deletion templates/credential-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concordium-cis2 = {version = "6.1", default-features = false}
quickcheck = {version = "1"}

[dev-dependencies]
concordium-smart-contract-testing = "4.0"
concordium-smart-contract-testing = "4.2"

[lib]
crate-type=["cdylib", "rlib"]
Expand Down
2 changes: 1 addition & 1 deletion templates/default/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bump_alloc = ["concordium-std/bump_alloc"]
concordium-std = {version = "10.0", default-features = false}

[dev-dependencies]
concordium-smart-contract-testing = "4.0"
concordium-smart-contract-testing = "4.2"

[lib]
crate-type=["cdylib", "rlib"]
Expand Down

0 comments on commit d874117

Please sign in to comment.