Skip to content

[sui move test] Use Sui's VM Conifg, Verifier Config, and Gas Meter in Unit Tests #25226

Merged
tnowacki merged 6 commits intoMystenLabs:mainfrom
tnowacki:ut-config
Feb 3, 2026
Merged

[sui move test] Use Sui's VM Conifg, Verifier Config, and Gas Meter in Unit Tests #25226
tnowacki merged 6 commits intoMystenLabs:mainfrom
tnowacki:ut-config

Conversation

@tnowacki
Copy link
Copy Markdown
Contributor

@tnowacki tnowacki commented Feb 2, 2026

Description

  • Fixed a long standing issue of not properly mirroring Sui's integration into the VM with unit tests
  • This should at least allow the numbers to line up a bit more when doing unit tests... though it might obliterate anyone that is manually setting the gas limit too low

Test plan

  • Ran tests

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):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI: sui move test now uses Sui's gas meter and limits.
  • Rust SDK:
  • Indexing Framework:

@tnowacki tnowacki requested a review from a team as a code owner February 2, 2026 22:41
@tnowacki tnowacki had a problem deploying to sui-typescript-aws-kms-test-env February 2, 2026 22:41 — with GitHub Actions Error
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview, Comment Feb 3, 2026 6:31pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Feb 3, 2026 6:31pm
sui-kiosk Ignored Ignored Preview Feb 3, 2026 6:31pm

Request Review

Comment on lines +79 to +80
let mut testing_config =
UnitTestingConfig::default_with_bound(Some(*MAX_UNIT_TEST_INSTRUCTIONS));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just called sui move test we wouldn't need this here


impl SuiVMTestSetup {
pub fn new() -> Self {
let reference_gas_price = 500;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a good place to get this constant @dariorussi @tzakian

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't one...this is probably as good as any ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move it to a constant then

impl SuiVMTestSetup {
pub fn new() -> Self {
let reference_gas_price = 500;
let gas_price = reference_gas_price;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this in to make it clear we can configure them if needed

};

pub struct SuiGasMeter<'g>(pub &'g mut GasStatus);
pub struct SuiGasMeter<G: DerefMut<Target = GasStatus>>(pub G);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit strange, but this change allows for either owned values or &mut values to be used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with switching this to AsRef + AsMut if the DerefMut makes folks skittish... it is a sharp trait in that it does a lot of things automatically

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fancy, but I'm fine with keeping it.

native_function_table: move_vm_runtime::native_functions::NativeFunctionTable,
}

impl Default for SuiVMTestSetup {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infinite sadness (hatred?).

I have lost this battle. I will go default() now.


impl SuiVMTestSetup {
pub fn new() -> Self {
let reference_gas_price = 500;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't one...this is probably as good as any ...

/// # Safety
/// This function exists solely for propagating a VMConfig down into the unit testing
/// environment. It should never be called anywhere else.
pub unsafe fn allow_unpublishable_for_move_unit_testing(&mut self) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the testing feature flag in the VM for enabling certain things only in CLI builds. Wondering if it would be useful plumbing that over into here for this function possibly?

};

pub struct SuiGasMeter<'g>(pub &'g mut GasStatus);
pub struct SuiGasMeter<G: DerefMut<Target = GasStatus>>(pub G);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fancy, but I'm fine with keeping it.


/// This function exists solely for propagating a VMConfig down into the unit testing
/// environment. It should never be called anywhere else.
#[cfg(feature = "testing")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 ❤️

Copy link
Copy Markdown
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for adding in the cfg gating.

@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env February 3, 2026 18:27 — with GitHub Actions Inactive
@tnowacki tnowacki enabled auto-merge (squash) February 3, 2026 18:27
@tnowacki tnowacki merged commit faa33a6 into MystenLabs:main Feb 3, 2026
53 of 54 checks passed
@tnowacki tnowacki deleted the ut-config branch February 3, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants