Skip to content

Commit 8678f46

Browse files
committed
test: add tests for group alignment
1 parent d0e10eb commit 8678f46

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/multichain-account-service/src/MultichainAccountGroup.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,38 @@ describe('MultichainAccount', () => {
146146
expect(group.select({ scopes: [SolScope.Mainnet] })).toStrictEqual([]);
147147
});
148148
});
149+
150+
describe('align', () => {
151+
it('creates missing accounts only for providers with no accounts', async () => {
152+
const groupIndex = 0;
153+
const { group, providers, wallet } = setup({
154+
groupIndex,
155+
accounts: [
156+
[MOCK_WALLET_1_EVM_ACCOUNT], // provider[0] already has group 0
157+
[], // provider[1] missing group 0
158+
],
159+
});
160+
161+
await group.align();
162+
163+
expect(providers[0].createAccounts).not.toHaveBeenCalled();
164+
expect(providers[1].createAccounts).toHaveBeenCalledWith({
165+
entropySource: wallet.entropySource,
166+
groupIndex,
167+
});
168+
});
169+
170+
it('does nothing when already aligned', async () => {
171+
const groupIndex = 0;
172+
const { group, providers } = setup({
173+
groupIndex,
174+
accounts: [[MOCK_WALLET_1_EVM_ACCOUNT], [MOCK_WALLET_1_SOL_ACCOUNT]],
175+
});
176+
177+
await group.align();
178+
179+
expect(providers[0].createAccounts).not.toHaveBeenCalled();
180+
expect(providers[1].createAccounts).not.toHaveBeenCalled();
181+
});
182+
});
149183
});

0 commit comments

Comments
 (0)