Skip to content

Commit

Permalink
add longer timeout to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
heliuchuan committed Feb 21, 2025
1 parent 106c926 commit c7bb90a
Showing 1 changed file with 87 additions and 87 deletions.
174 changes: 87 additions & 87 deletions tests/e2e/api/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,110 +390,110 @@ describe("account api", () => {
address: account.accountAddress,
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
});
});
}, 10000);

test("it should rotate ed25519 to multi-ed25519 auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
test("it should rotate ed25519 to multi-ed25519 auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });
// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });

const mk1 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const mk2 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const multiEdAccount = new MultiEd25519Account({
publicKey: new MultiEd25519PublicKey({
publicKeys: [mk1.publicKey, mk2.publicKey],
threshold: 1,
}),
signers: [mk1.privateKey],
});
const mk1 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const mk2 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const multiEdAccount = new MultiEd25519Account({
publicKey: new MultiEd25519PublicKey({
publicKeys: [mk1.publicKey, mk2.publicKey],
threshold: 1,
}),
signers: [mk1.privateKey],
});

// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({ fromAccount: account, toAccount: multiEdAccount });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });
// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({ fromAccount: account, toAccount: multiEdAccount });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });

const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(multiEdAccount.publicKey.authKey().toString());
const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(multiEdAccount.publicKey.authKey().toString());

const rotatedAccount = new MultiEd25519Account({
publicKey: new MultiEd25519PublicKey({
publicKeys: [mk1.publicKey, mk2.publicKey],
threshold: 1,
}),
signers: [mk1.privateKey],
address: account.accountAddress,
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
});
const rotatedAccount = new MultiEd25519Account({
publicKey: new MultiEd25519PublicKey({
publicKeys: [mk1.publicKey, mk2.publicKey],
threshold: 1,
}),
signers: [mk1.privateKey],
address: account.accountAddress,
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
}, 10000);

test("it should rotate ed25519 to multikey auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
test("it should rotate ed25519 to multikey auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });
// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });

const mk1 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const mk2 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const multiKeyAccount = MultiKeyAccount.fromPublicKeysAndSigners({
publicKeys: [mk1.publicKey, mk2.publicKey],
signaturesRequired: 1,
signers: [mk1],
});
const mk1 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const mk2 = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
const multiKeyAccount = MultiKeyAccount.fromPublicKeysAndSigners({
publicKeys: [mk1.publicKey, mk2.publicKey],
signaturesRequired: 1,
signers: [mk1],
});

// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({ fromAccount: account, toAccount: multiKeyAccount });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });
// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({ fromAccount: account, toAccount: multiKeyAccount });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });

const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(multiKeyAccount.publicKey.authKey().toString());
const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(multiKeyAccount.publicKey.authKey().toString());

const rotatedAccount = MultiKeyAccount.fromPublicKeysAndSigners({
address: account.accountAddress,
publicKeys: [mk1.publicKey, mk2.publicKey],
signaturesRequired: 1,
signers: [mk1],
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
});
const rotatedAccount = MultiKeyAccount.fromPublicKeysAndSigners({
address: account.accountAddress,
publicKeys: [mk1.publicKey, mk2.publicKey],
signaturesRequired: 1,
signers: [mk1],
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
}, 10000);

test("it should rotate ed25519 to unverified auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);
test("it should rotate ed25519 to unverified auth key correctly", async () => {
const config = new AptosConfig({ network: Network.LOCAL });
const aptos = new Aptos(config);

// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });
// Current Account
const account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: true });
await aptos.fundAccount({ accountAddress: account.accountAddress, amount: 1_000_000_000 });

// account that holds the new key
const newAccount = Account.generate();
const newAuthKey = newAccount.publicKey.authKey();
// account that holds the new key
const newAccount = Account.generate();
const newAuthKey = newAccount.publicKey.authKey();

// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({
fromAccount: account,
toAuthKey: newAuthKey,
dangerouslySkipVerification: true,
});
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });
// Rotate the key
const pendingTxn = await aptos.rotateAuthKey({
fromAccount: account,
toAuthKey: newAuthKey,
dangerouslySkipVerification: true,
});
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });

const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(newAuthKey.toString());
const accountInfo = await aptos.account.getAccountInfo({
accountAddress: account.accountAddress,
});
expect(accountInfo.authentication_key).toEqual(newAuthKey.toString());

const rotatedAccount = Account.fromPrivateKey({
privateKey: newAccount.privateKey,
address: newAccount.accountAddress,
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
const rotatedAccount = Account.fromPrivateKey({
privateKey: newAccount.privateKey,
address: newAccount.accountAddress,
});
await simpleCoinTransactionHeler(aptos, rotatedAccount, Account.generate());
}, 10000);
});
});

0 comments on commit c7bb90a

Please sign in to comment.