test(precompiles): add golden tests for asset V1 (BOP-423)#3972
test(precompiles): add golden tests for asset V1 (BOP-423)#3972stephancill wants to merge 5 commits into
Conversation
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
🟡 Heimdall Review Status
|
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
…pwire Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
| use alloy_sol_types::{SolCall, SolError, SolEvent, SolInterface, SolValue}; | ||
| use base_common_genesis::BaseUpgrade; | ||
| use base_common_precompiles::{ | ||
| Asset, AssetAccounting, AssetV1, AssetVersion, AssetVersions, B20_MAX_SUPPLY_CAP, B20AssetInit, | ||
| B20AssetStorage, B20AssetToken, B20PolicyType, B20TokenRole, IB20, IB20Asset, InMemoryPolicy, | ||
| NoopPrecompileCallObserver, PermitArgs, TokenAccounting, |
There was a problem hiding this comment.
Three unused imports: SolError (line 24), Asset and TokenAccounting (lines 27, 29). Clippy should catch these — remove them to keep CI clean.
| use alloy_sol_types::{SolCall, SolError, SolEvent, SolInterface, SolValue}; | |
| use base_common_genesis::BaseUpgrade; | |
| use base_common_precompiles::{ | |
| Asset, AssetAccounting, AssetV1, AssetVersion, AssetVersions, B20_MAX_SUPPLY_CAP, B20AssetInit, | |
| B20AssetStorage, B20AssetToken, B20PolicyType, B20TokenRole, IB20, IB20Asset, InMemoryPolicy, | |
| NoopPrecompileCallObserver, PermitArgs, TokenAccounting, | |
| use alloy_sol_types::{SolCall, SolEvent, SolInterface, SolValue}; | |
| use base_common_genesis::BaseUpgrade; | |
| use base_common_precompiles::{ | |
| AssetAccounting, AssetV1, AssetVersion, AssetVersions, B20_MAX_SUPPLY_CAP, B20AssetInit, | |
| B20AssetStorage, B20AssetToken, B20PolicyType, B20TokenRole, IB20, IB20Asset, InMemoryPolicy, | |
| NoopPrecompileCallObserver, PermitArgs, |
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
Review SummaryTest-only PR adding golden/snapshot tests for Asset V1 — no production code changes. One finding (already raised inline): three unused imports ( No other issues. The test harness is well-designed: each test gets an isolated |
✅ base-std fork tests: all 616 passedbase/base is fully in sync with the base-std spec.
|
Summary
Adds a golden/snapshot test suite pinning current Asset V1 behavior of the B-20 precompile (BOP-423), before/while it is frozen behind the versioning seam introduced in #3969 (BOP-417). Sibling of the stablecoin golden suite (#3971).
Every op is driven through the version-resolver-gated path (
inner(..., BaseUpgrade::Beryl)→AssetVersions::from_base_upgrade→ V1) against the real EVM-backedB20AssetStorageoverHashMapStorageProvider, withInMemoryPolicyfor deterministic allow/block. Each mutation case asserts:Coverage: the shared B-20 surface (transfer / transferFrom / approve + memo variants, mint / burn / burnBlocked, pause / unpause, updateSupplyCap|Name|Symbol|ContractURI, grant/revoke/renounce/renounceLastAdmin/setRoleAdmin, updatePolicy, permit, all reads + role/policy constants), plus the asset-specific ops:
updateMultiplier(operator role, zero-reject),updateExtraMetadata(empty-key reject),batchMint(length-mismatch / empty-batch),announce(internal-call loop, reused-id, nested-announce, malformed / failing internal call), and the scaled-balance reads (multiplier,toScaledBalance,toRawBalance,scaledBalanceOf, configurabledecimals). Privileged vs unprivileged viainner_with_privilegevsinner; the guard envelope (nonpayable / uninitialized / pre-Beryl) via fulldispatch_with_observer.No source/logic changes — frozen V1 is untouched; only a new integration test file and one
[[test]]stanza are added.Testing
cargo test -p base-common-precompiles --features test-utils --test b20_asset_v1_golden→ 68 passedcargo test -p base-common-precompiles --features test-utils→ 486 + 68 passed--all-targets) and fmt cleanState-roots are pinned; regenerate with
BLESS_GOLDEN=1 cargo test ... -- --nocapture(documented in the file header).