Skip to content

Add comprehensive test coverage for pallet-robonomics-rws v2.0 auction lifecycle#396

Merged
akru merged 5 commits intofeat/rws2_0from
copilot/add-tests-for-auction-lifecycle
Nov 28, 2025
Merged

Add comprehensive test coverage for pallet-robonomics-rws v2.0 auction lifecycle#396
akru merged 5 commits intofeat/rws2_0from
copilot/add-tests-for-auction-lifecycle

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

PR #381 refactored the RWS pallet to a two-phase auction system (bid → claim) with static auction scheme, but lacked test coverage. This PR adds 24 tests covering auction lifecycle, subscriptions, and failure modes.

Changes

Test Infrastructure

  • Updated mock runtime to current Substrate patterns (RuntimeOrigin, RuntimeCall, RuntimeEvent)
  • Configured test dependencies (Balances, Timestamp only - no external pallet dependencies)
  • Enabled previously commented-out test module

Test Coverage (24 tests)

Auction Lifecycle

  • Start auctions with lifetime/daily subscription modes
  • Multiple concurrent auctions

Bidding

  • First bid becomes winner, outbidding mechanics
  • Validation: minimum bid, non-existent auction, expired period

Claiming

  • Successful claim by winner post-auction
  • Beneficiary assignment (claim to different account)
  • Validation: early claim, non-winner, double claim

Subscription Usage

  • RWS calls with lifetime/daily subscriptions (using pallet_balances::Call::transfer_allow_death as mock transactions)
  • Free weight accumulation via formula: ReferenceCallWeight × uTPS × delta_ms / 1_000_000_000
  • Validation: insufficient weight, expired subscription, non-existent subscription

Edge Cases

  • Insufficient balance, expiration boundaries, weight calculation accuracy, multiple subscriptions per user

Example Test

#[test]
fn test_bid_outbidding() {
    new_test_ext().execute_with(|| {
        assert_ok!(RWS::start_auction(RuntimeOrigin::root(), SubscriptionMode::Lifetime { tps: 50_000 }));
        
        // Alice bids first
        assert_ok!(RWS::bid(RuntimeOrigin::signed(ALICE), 0, 200));
        assert_eq!(Balances::reserved_balance(ALICE), 200);
        
        // Bob outbids Alice
        assert_ok!(RWS::bid(RuntimeOrigin::signed(BOB), 0, 300));
        
        // Alice's reserve unreserved, Bob's reserved
        assert_eq!(Balances::reserved_balance(ALICE), 0);
        assert_eq!(Balances::reserved_balance(BOB), 300);
    });
}

All tests pass. No clippy warnings in test code.

Original prompt

Check #381 and add tests into pallet-robonomics-rws that covers all functionality. Focus on auction life cycle, subscriptions and fail cases. You can use pallet-balances for mock transactions.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 28, 2025 13:28
…fecycle, subscriptions, and fail cases

Co-authored-by: akru <786394+akru@users.noreply.github.com>
Co-authored-by: akru <786394+akru@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for auction life cycle and subscriptions Add comprehensive test coverage for pallet-robonomics-rws v2.0 auction lifecycle Nov 28, 2025
Copilot AI requested a review from akru November 28, 2025 13:38
@akru
Copy link
Member

akru commented Nov 28, 2025

@copilot Don't use pallet-robonomics-datalog here, please cleanup all mentions.

…lances calls instead

Co-authored-by: akru <786394+akru@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot Don't use pallet-robonomics-datalog here, please cleanup all mentions.

Removed all pallet-robonomics-datalog references. Tests now use pallet-balances::Call::transfer_allow_death for RWS subscription testing. All 24 tests still pass. (0de7d36)

@akru akru marked this pull request as ready for review November 28, 2025 14:01
@akru akru merged commit 65828af into feat/rws2_0 Nov 28, 2025
@akru akru deleted the copilot/add-tests-for-auction-lifecycle branch November 28, 2025 14:01
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