Skip to content

Commit 3baec0d

Browse files
Release support for protocol 7 (#446)
* Get rid of clippy warnings * Fmt * Expect deprecation of testing infrastructure module * Bump versions * Allow instead of expect * Make separate paragraph * Change date in changelog
1 parent 74d6474 commit 3baec0d

File tree

12 files changed

+45
-63
lines changed

12 files changed

+45
-63
lines changed

concordium-cis2/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Unreleased changes
3+
## concordium-cis2 6.2.0 (2024-09-19)
44

55
- Bump MSRV to 1.72
66
- Add `FromStr` implementations for `TokenId` types.

concordium-cis2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "concordium-cis2"
3-
version = "6.1.0"
3+
version = "6.2.0"
44
authors = ["Concordium <[email protected]>"]
55
rust-version = "1.73"
66
edition = "2021"

concordium-cis2/src/cis2_client.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ impl Cis2Client {
389389

390390
#[cfg(test)]
391391
mod test {
392+
// concordium_std::test_infrastructure is deprecated and should on the long term be replaced with concordium-smart-contract-testing, see also https://github.com/Concordium/concordium-rust-smart-contracts/issues/341
393+
#![allow(deprecated)]
394+
392395
use crate::*;
393396
use concordium_std::test_infrastructure::*;
394397

@@ -538,9 +541,7 @@ mod test {
538541
};
539542

540543
// Return a response with operator true.
541-
Ok((false, OperatorOfQueryResponse {
542-
0: vec![true],
543-
}))
544+
Ok((false, OperatorOfQueryResponse(vec![true])))
544545
}
545546

546547
host.setup_mock_entrypoint(
@@ -551,9 +552,9 @@ mod test {
551552

552553
let client = Cis2Client::new(cis_contract_address);
553554
let res: Result<bool, Cis2ClientError<()>> =
554-
client.operator_of(&mut host, owner, current_contract_address);
555+
client.operator_of(&host, owner, current_contract_address);
555556

556-
assert_eq!(res.unwrap(), true);
557+
assert!(res.unwrap());
557558
}
558559

559560
#[test]

concordium-std/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
//! to do the following two steps:
323323
//!
324324
//! 1. Replace the usage of deprecated traits with their concrete alternatives
325-
//! and remove generics.
325+
//! and remove generics.
326326
//!
327327
//! For init methods:
328328
//! ```no_run
@@ -372,8 +372,8 @@
372372
//! ```
373373
//!
374374
//! If you use logging, crypto-primitives, or similar, you must also
375-
//! replace those uses of traits with concrete types. E.g. replacing `&mut impl
376-
//! HasLogger` with `&mut Logger`.
375+
//! replace those uses of traits with concrete types. E.g. replacing `&mut
376+
//! impl HasLogger` with `&mut Logger`.
377377
//!
378378
//! 2. Migrate your tests to use the new testing library.
379379
//!

concordium-std/src/prims.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,17 @@ extern "C" {
126126
/// - all but second bit set to 1 if there is no value in the state with the
127127
/// given key
128128
/// - otherwise the first bit is 0, and the remaining bits are the iterator
129-
/// identifier
130-
/// that may be used in subsequent calls to advance it, or to get its key.
129+
/// identifier that may be used in subsequent calls to advance it, or to
130+
/// get its key.
131131
pub fn state_iterate_prefix(prefix_start: *const u8, prefix_length: u32) -> u64;
132132

133133
/// Return the next entry along the iterator, and advance the iterator.
134134
/// The return value is
135135
/// - u64::MAX if the iterator does not exist (it was deleted, or the ID is
136136
/// invalid)
137137
/// - all but the second bit set to 1 if no more entries are left, the
138-
/// iterator
139-
/// is exhausted. All further calls will yield the same until the iterator
140-
/// is deleted.
138+
/// iterator is exhausted. All further calls will yield the same until the
139+
/// iterator is deleted.
141140
/// - otherwise the first bit is 0, and the remaining bits encode an entry
142141
/// identifier that can be passed to any of the entry methods.
143142
pub fn state_iterator_next(iterator: u64) -> u64;
@@ -159,11 +158,12 @@ extern "C" {
159158
/// - u32::MAX if the iterator has already been deleted
160159
/// - the amount of data that was copied. This will never be more than the
161160
/// supplied length.
162-
/// Before the first call to the [state_iterator_next] function this returns
163-
/// (sections of) the key that was used to create the iterator. After
164-
/// [state_iterator_next] returns (the encoding of) [None] this method
165-
/// returns (sections of) the key at the first node returned by the
166-
/// iterator.
161+
///
162+
/// Before the first call to the [state_iterator_next]
163+
/// function this returns (sections of) the key that was used to create
164+
/// the iterator. After [state_iterator_next] returns (the encoding of)
165+
/// [None] this method returns (sections of) the key at the first node
166+
/// returned by the iterator.
167167
pub fn state_iterator_key_read(iterator: u64, start: *mut u8, length: u32, offset: u32) -> u32;
168168

169169
// Operations on the entry.
@@ -175,7 +175,7 @@ extern "C" {
175175
/// offset ... where to start reading in the entry
176176
/// The return value is
177177
/// - u32::MAX if the entry does not exist (has been invalidated, or never
178-
/// existed). In this case no data is written.
178+
/// existed). In this case no data is written.
179179
/// - amount of data that was read. This is never more than length.
180180
pub fn state_entry_read(entry: u64, start: *mut u8, length: u32, offset: u32) -> u32;
181181

@@ -186,14 +186,14 @@ extern "C" {
186186
/// offset ... where to start writing in the entry
187187
/// The return value is
188188
/// - u32::MAX if the entry does not exist (has been invalidated, or never
189-
/// existed). In this case no data is written.
189+
/// existed). In this case no data is written.
190190
/// - amount of data that was written. This is never more than length.
191191
pub fn state_entry_write(entry: u64, start: *const u8, length: u32, offset: u32) -> u32;
192192

193193
/// Return the current size of the entry in bytes.
194194
/// The return value is either
195195
/// - u32::MAX if the entry does not exist (has been invalidated, or never
196-
/// existed). In this case no data is written.
196+
/// existed). In this case no data is written.
197197
/// - or the size of the entry.
198198
pub fn state_entry_size(entry: u64) -> u32;
199199

concordium-std/src/state_btree.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
505505
pub fn higher(&self, key: &K) -> Option<StateRef<K>>
506506
where
507507
K: Serialize + Ord, {
508-
let Some(root_node_id) = self.root else {
509-
return None;
510-
};
508+
let root_node_id = self.root?;
511509

512510
let mut node = self.get_node(root_node_id);
513511
let mut higher_so_far = None;
@@ -543,9 +541,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
543541
pub fn eq_or_higher(&self, key: &K) -> Option<StateRef<K>>
544542
where
545543
K: Serialize + Ord, {
546-
let Some(root_node_id) = self.root else {
547-
return None;
548-
};
544+
let root_node_id = self.root?;
549545

550546
let mut node = self.get_node(root_node_id);
551547
let mut higher_so_far = None;
@@ -581,9 +577,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
581577
pub fn lower(&self, key: &K) -> Option<StateRef<K>>
582578
where
583579
K: Serialize + Ord, {
584-
let Some(root_node_id) = self.root else {
585-
return None;
586-
};
580+
let root_node_id = self.root?;
587581

588582
let mut node = self.get_node(root_node_id);
589583
let mut lower_so_far = None;
@@ -614,9 +608,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
614608
pub fn eq_or_lower(&self, key: &K) -> Option<StateRef<K>>
615609
where
616610
K: Serialize + Ord, {
617-
let Some(root_node_id) = self.root else {
618-
return None;
619-
};
611+
let root_node_id = self.root?;
620612

621613
let mut node = self.get_node(root_node_id);
622614
let mut lower_so_far = None;
@@ -651,9 +643,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
651643
pub fn first(&self) -> Option<StateRef<K>>
652644
where
653645
K: Serialize + Ord, {
654-
let Some(root_node_id) = self.root else {
655-
return None;
656-
};
646+
let root_node_id = self.root?;
657647
let mut root = self.get_node(root_node_id);
658648
if root.is_leaf() {
659649
Some(StateRef::new(root.keys.swap_remove(0)))
@@ -667,9 +657,7 @@ impl<const M: usize, K> StateBTreeSet<K, M> {
667657
pub fn last(&self) -> Option<StateRef<K>>
668658
where
669659
K: Serialize + Ord, {
670-
let Some(root_node_id) = self.root else {
671-
return None;
672-
};
660+
let root_node_id = self.root?;
673661
let mut root = self.get_node(root_node_id);
674662
if root.is_leaf() {
675663
Some(StateRef::new(root.keys.pop().unwrap_abort()))

concordium-std/src/test_infrastructure.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,9 @@ type MockFnHash<T> = Box<dyn FnMut(&[u8]) -> T>;
780780
/// two different ways:
781781
///
782782
/// 1. By setting up mock responses for the functions you need, for example with
783-
/// the `setup_hash_sha_256_mock` method.
783+
/// the `setup_hash_sha_256_mock` method.
784784
/// 2. Or, by using the actual implementations. For this, you need to enable the
785-
/// "crypto-primitives" feature.
785+
/// "crypto-primitives" feature.
786786
pub struct TestCryptoPrimitives {
787787
#[cfg(not(feature = "crypto-primitives"))]
788788
verify_ed25519_signature_mock: RefCell<Option<MockFnVerifyEd25519>>,
@@ -1928,17 +1928,10 @@ pub fn concordium_qc<A: Testable>(num_tests: u64, f: A) {
19281928
}
19291929

19301930
#[cfg(test)]
1931+
#[allow(deprecated)]
19311932
mod test {
1932-
1933-
use super::TestStateApi;
1934-
use crate::{
1935-
cell::RefCell,
1936-
rc::Rc,
1937-
test_infrastructure::{TestStateBuilder, TestStateEntry},
1938-
Deletable, EntryRaw, HasStateApi, HasStateEntry, StateBTreeSet, StateMap, StateSet,
1939-
INITIAL_NEXT_ITEM_PREFIX,
1940-
};
1941-
use concordium_contracts_common::{to_bytes, Deserial, Read, Seek, SeekFrom, Write};
1933+
use crate::{cell::RefCell, rc::Rc, test_infrastructure::TestStateEntry, HasStateEntry};
1934+
use concordium_contracts_common::{Read, Seek, SeekFrom, Write};
19421935

19431936
#[test]
19441937
fn test_testhost_balance_queries_reflect_transfers() {

contract-testing/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Unreleased changes
3+
## 4.3.0
44

55
- Integrate protocol version 7 cost semantics.
66
- The `ContractInvokeSuccess` and `ContractInvokeError` have additional fields

contract-testing/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
22
name = "concordium-smart-contract-testing"
3-
version = "4.2.0"
3+
version = "4.3.0"
44
edition = "2021"
55
rust-version = "1.73"
66
license = "MPL-2.0"
77
readme = "README.md"
88
description = "A companion crate to `concordium-std` that supports off-chain end-to-end testing of smart contracts."
99
homepage = "https://github.com/Concordium/concordium-rust-smart-contracts"
1010
repository = "https://github.com/Concordium/concordium-rust-smart-contracts"
11-
exclude = ["tests"] # Do not publish tests.
11+
exclude = ["tests"] # Do not publish tests.
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
concordium-rust-sdk = {version = "4", path = "../concordium-rust-sdk"}
16+
concordium-rust-sdk = { version = "5", path = "../concordium-rust-sdk" }
1717
tokio = { version = "1.28", features = ["rt-multi-thread", "time"] }
1818
sha2 = "0.10"
1919
anyhow = "1"

0 commit comments

Comments
 (0)