Skip to content

Commit

Permalink
[test] Move coin deny list tests to authority tests (#18290)
Browse files Browse the repository at this point in the history
## Description 

The coin deny list v1 tests can be run in a single authority, without a
cluster.

## Test plan 

CI

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
lxfind authored Jun 17, 2024
1 parent 842cd17 commit baea133
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 26 deletions.
4 changes: 4 additions & 0 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ mod gas_tests;
#[path = "unit_tests/batch_verification_tests.rs"]
mod batch_verification_tests;

#[cfg(test)]
#[path = "unit_tests/coin_deny_list_tests.rs"]
mod coin_deny_list_tests;

#[cfg(any(test, feature = "test-utils"))]
pub mod authority_test_utils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use std::path::PathBuf;
use sui_json_rpc_types::SuiTransactionBlockEffectsAPI;
use sui_macros::sim_test;
use sui_types::deny_list_v1::CoinDenyCap;
use sui_types::deny_list_v1::RegulatedCoinMetadata;
use test_cluster::TestClusterBuilder;
use crate::authority::move_integration_tests::build_and_try_publish_test_package;
use crate::authority::test_authority_builder::TestAuthorityBuilder;
use sui_types::crypto::get_account_key_pair;
use sui_types::deny_list_v1::{CoinDenyCap, RegulatedCoinMetadata};
use sui_types::effects::TransactionEffectsAPI;
use sui_types::object::Object;
use sui_types::transaction::TEST_ONLY_GAS_UNIT_FOR_PUBLISH;

#[sim_test]
// Test that a regulated coin can be created and all the necessary objects are created with the right types.
// Make sure that these types can be converted to Rust types.
#[tokio::test]
async fn test_regulated_coin_v1_creation() {
let test_cluster = TestClusterBuilder::new().build().await;
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/move_test_code");
let tx_data = test_cluster
.test_transaction_builder()
.await
.publish(path)
.build();
let effects = test_cluster
.sign_and_execute_transaction(&tx_data)
.await
.effects
.unwrap();
let (sender, keypair) = get_account_key_pair();
let gas_object = Object::with_owner_for_testing(sender);
let gas_object_id = gas_object.id();
let authority = TestAuthorityBuilder::new()
.with_starting_objects(&[gas_object])
.build()
.await;
let rgp = authority.reference_gas_price_for_testing().unwrap();
let (_, effects) = build_and_try_publish_test_package(
&authority,
&sender,
&keypair,
&gas_object_id,
"coin_deny_list_v1",
TEST_ONLY_GAS_UNIT_FOR_PUBLISH * rgp,
rgp,
false,
)
.await;

let mut deny_cap_object = None;
let mut metadata_object = None;
let mut regulated_metadata_object = None;
for created in effects.created() {
let object = test_cluster
.get_object_from_fullnode_store(&created.object_id())
.await
.unwrap();
for (oref, _owner) in effects.created() {
let object = authority.get_object(&oref.0).await.unwrap().unwrap();
if object.is_package() {
continue;
}
Expand Down
10 changes: 10 additions & 0 deletions crates/sui-core/src/unit_tests/data/coin_deny_list_v1/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "coin_deny_list_v1"
version = "0.0.1"
edition = "2024.beta"

[dependencies]
Sui = { local = "../../../../../sui-framework/packages/sui-framework" }

[addresses]
coin_deny_list_v1 = "0x0"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

module move_test_code::regulated_coin {
module coin_deny_list_v1::regulated_coin {
use std::option;
use sui::coin;
use sui::object::UID;
Expand Down

0 comments on commit baea133

Please sign in to comment.