Skip to content

Commit

Permalink
[framework, tests] Adds convenience method for testing (#15893)
Browse files Browse the repository at this point in the history
## Description 

Adds some test-only methods for overall convenience in testing.

## Test Plan 

I am test.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
damirka authored Jan 24, 2024
1 parent a3971c3 commit f6504b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ module sui::balance {

/// For when trying to destroy a non-zero balance.
const ENonZero: u64 = 0;

/// For when an overflow is happening on Supply operations.
const EOverflow: u64 = 1;

/// For when trying to withdraw more than there is.
const ENotEnough: u64 = 2;

/// Sender is not @0x0 the system address.
const ENotSystemAddress: u64 = 3;

Expand Down
2 changes: 0 additions & 2 deletions crates/sui-framework/packages/sui-framework/sources/bcs.move
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ module sui::bcs {

/// For when bytes length is less than required for deserialization.
const EOutOfRange: u64 = 0;

/// For when the boolean value different than `0` or `1`.
const ENotBool: u64 = 1;

/// For when ULEB byte is out of range (or not found).
const ELenOutOfRange: u64 = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,18 @@ module sui::transfer_policy {

/// Get the `from` field of the `TransferRequest`.
public fun from<T>(self: &TransferRequest<T>): ID { self.from }

// === Tests ===

#[test_only]
/// Create a new TransferPolicy for testing purposes.
public fun new_for_testing<T>(ctx: &mut TxContext): (TransferPolicy<T>, TransferPolicyCap<T>) {
let id = object::new(ctx);
let policy_id = object::uid_to_inner(&id);

(
TransferPolicy { id, rules: vec_set::empty(), balance: balance::zero() },
TransferPolicyCap { id: object::new(ctx), policy_id }
)
}
}

0 comments on commit f6504b9

Please sign in to comment.