Skip to content

Commit

Permalink
Update casper crates. (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
zie1ony authored May 11, 2023
1 parent 4b42b52 commit 4059ea0
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt, clippy
override: true
- run: just prepare
- run: just check-lint
- run: just test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2023-05-11

### Changed

- Updated casper crates to `2.0.0`.

## [0.2.0] - 2023-02-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
]

[workspace.package]
version = "0.2.0"
version = "0.3.0"
authors = ["Maciej Zieliński <[email protected]>"]
description = "The smart contract level events for Casper."
edition = "2021"
Expand Down
6 changes: 3 additions & 3 deletions casper-event-standard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ license.workspace = true
doctest = false

[dependencies]
casper-types = "1.5.0"
casper-event-standard-macro = { version = "0.2.0", path = "../casper-event-standard-macro" }
casper-types = "2.0.0"
casper-event-standard-macro = { version = "0.3.0", path = "../casper-event-standard-macro" }
serde = { version = "1.0", features = ["derive"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
casper-contract = { version = "1.4.4", default-features = false }
casper-contract = { version = "2.0.0", default-features = false }

[package.metadata.docs.rs]
default-target = "wasm32-unknown-unknown"
Expand Down
9 changes: 5 additions & 4 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ version = "0.1.0"
edition = "2021"

[dependencies]
casper-types = "1.5.0"
casper-types = "2.0.0"
casper-event-standard = { path = "../casper-event-standard" }
casper-contract = { version = "1.4.4", optional = true }
casper-engine-test-support = { version = "2.0.3", optional = true }
casper-contract = { version = "2.0.0", optional = true }
casper-engine-test-support = { version = "4.0.0", optional = true }
casper-execution-engine = { version = "4.0.0", optional = true }

[features]
default = ["test-support", "contract-support"]
contract-support = [ "dep:casper-contract" ]
test-support = [ "dep:casper-engine-test-support" ]
test-support = [ "dep:casper-engine-test-support", "dep:casper-execution-engine" ]

[[bin]]
name = "event_producer"
Expand Down
55 changes: 45 additions & 10 deletions integration-tests/tests/vm_tests.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,61 @@
use casper_engine_test_support::{
ExecuteRequestBuilder, InMemoryWasmTestBuilder, DEFAULT_ACCOUNT_ADDR,
DEFAULT_RUN_GENESIS_REQUEST,
ExecuteRequestBuilder, InMemoryWasmTestBuilder, DEFAULT_ACCOUNT_INITIAL_BALANCE,
DEFAULT_GENESIS_CONFIG, DEFAULT_GENESIS_CONFIG_HASH,
};
use casper_event_standard::{
Schemas, CES_VERSION, CES_VERSION_KEY, EVENTS_DICT, EVENTS_LENGTH, EVENTS_SCHEMA,
};
use casper_execution_engine::core::engine_state::{
run_genesis_request::RunGenesisRequest, GenesisAccount,
};
use casper_types::{
account::AccountHash,
bytesrepr::{Bytes, FromBytes},
contracts::NamedKeys,
Key, RuntimeArgs, StoredValue, URef,
Key, Motes, PublicKey, RuntimeArgs, SecretKey, StoredValue, URef, U512,
};
use integration_tests::{Mint, Transfer};

struct TestEnv {
context: InMemoryWasmTestBuilder,
account_addr: AccountHash,
}

impl TestEnv {
pub fn new() -> TestEnv {
// Create keypair.
let secret_key = SecretKey::ed25519_from_bytes([7u8; 32]).unwrap();
let public_key = PublicKey::from(&secret_key);

// Create an AccountHash from a public key.
let account_addr = AccountHash::from(&public_key);
// Create a GenesisAccount.
let account = GenesisAccount::account(
public_key,
Motes::new(U512::from(DEFAULT_ACCOUNT_INITIAL_BALANCE)),
None,
);

let mut genesis_config = DEFAULT_GENESIS_CONFIG.clone();
genesis_config.ee_config_mut().push_account(account);

let run_genesis_request = RunGenesisRequest::new(
*DEFAULT_GENESIS_CONFIG_HASH,
genesis_config.protocol_version(),
genesis_config.take_ee_config(),
);

let mut context = InMemoryWasmTestBuilder::default();
context.run_genesis(&DEFAULT_RUN_GENESIS_REQUEST).commit();
TestEnv { context }
context.run_genesis(&run_genesis_request).commit();

TestEnv {
context,
account_addr,
}
}

pub fn default_account(&self) -> AccountHash {
self.account_addr
}

pub fn deploy_event_producer_wasm(&mut self) {
Expand All @@ -33,13 +68,13 @@ impl TestEnv {

pub fn named_keys(&self) -> NamedKeys {
self.context
.get_expected_account(*DEFAULT_ACCOUNT_ADDR)
.get_expected_account(self.default_account())
.named_keys()
.clone()
}

pub fn schemas(&self) -> Schemas {
let key = Key::from(*DEFAULT_ACCOUNT_ADDR);
let key = Key::from(self.default_account());
self.context
.query(None, key, &[String::from(EVENTS_SCHEMA)])
.unwrap()
Expand All @@ -51,7 +86,7 @@ impl TestEnv {
}

pub fn events_length(&self) -> u32 {
let key = Key::from(*DEFAULT_ACCOUNT_ADDR);
let key = Key::from(self.default_account());
self.context
.query(None, key, &[String::from(EVENTS_LENGTH)])
.unwrap()
Expand All @@ -63,7 +98,7 @@ impl TestEnv {
}

pub fn ces_version(&self) -> String {
let key = Key::from(*DEFAULT_ACCOUNT_ADDR);
let key = Key::from(self.default_account());
self.context
.query(None, key, &[String::from(CES_VERSION_KEY)])
.unwrap()
Expand Down Expand Up @@ -95,7 +130,7 @@ impl TestEnv {

fn deploy_wasm(&mut self, name: &str) {
let wasm_exec_request =
ExecuteRequestBuilder::standard(*DEFAULT_ACCOUNT_ADDR, name, RuntimeArgs::new())
ExecuteRequestBuilder::standard(self.default_account(), name, RuntimeArgs::new())
.build();

self.context
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2022-10-28
5 changes: 0 additions & 5 deletions rust-toolchain.toml

This file was deleted.

0 comments on commit 4059ea0

Please sign in to comment.