Skip to content

Creating a scenario for multiple Users (instead of just single User, multiple accounts)#33

Draft
vivek-arte wants to merge 1 commit into
mainfrom
move_to_mult_users
Draft

Creating a scenario for multiple Users (instead of just single User, multiple accounts)#33
vivek-arte wants to merge 1 commit into
mainfrom
move_to_mult_users

Conversation

@vivek-arte

Copy link
Copy Markdown
Contributor

This PR prepares the same three party scenario present in test_three_party, but does it by using multiple Users, rather than a single User with multiple accounts.

This is done in a backward-compatible manner, via the addition of extra supporting structure that does not break any of the existing code.

@vivek-arte vivek-arte left a comment

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.

Added some comments where suggestions would be welcome.

Also, there is a User::address_for_account method to generate a new address -- if we want to support multiple Users and multiple accounts, I can see it being useful to have a way of querying how many accounts have been generated by a User. Is there a reason against having such a function?

TestBalances(balances)
}

pub(crate) fn get_asset_balances_multi_user(

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 make this function work without num_users, since I can get it from wallets.length().

asset: AssetBase,
expected_balances: &TestBalances,
wallets: &mut [&mut User],
num_users: usize,

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.

Again here, could get rid of num_users as above.

Comment on lines +105 to +106
let from_addr = wallets[self.acc_idx_from].address_for_account(0, External);
let to_addr = wallets[self.acc_idx_to].address_for_account(0, External);

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.

Note that I have multiple Users, but I am using "account" 0 for them all. I don't support multiple accounts per User at the moment.

Comment on lines +37 to +53
let mut manufacturer = User::random(&config.wallet.miner_seed_phrase);
let mut purchaser = User::random(&config.wallet.miner_seed_phrase);
let mut supplier = User::random(&config.wallet.miner_seed_phrase);
let mut miner = User::random(&config.wallet.miner_seed_phrase);

manufacturer.reset();
purchaser.reset();
supplier.reset();
miner.reset();

let manufacturer_addr = manufacturer.address_for_account(0, External);

let mut wallets = [&mut manufacturer, &mut purchaser, &mut supplier, &mut miner];
let manufacturer_idx = 0;
let purchaser_idx = 1;
let supplier_idx = 2;
let miner_idx = 3;

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.

There is a lot of repetition here, could be improved, but as an initial proof-of-concept that it works I didn't get into it yet.

@PaulLaux PaulLaux marked this pull request as draft October 29, 2025 07:10
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.

1 participant