Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Jan 30, 2025
1 parent 94d246c commit ff2520e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
9 changes: 2 additions & 7 deletions src/abi/smartContract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ describe("test contract", () => {
address: new Address("erd1qqqqqqqqqqqqqpgqak8zt22wl2ph4tswtyc39namqx6ysa2sd8ss4xmlj3"),
});

provider.mockUpdateAccount(alice.address, (account) => {
account.nonce = 42n;
});
alice.nonce = 42n;

let callTransactionOne = contract.call({
func: new ContractFunction("helloEarth"),
Expand Down Expand Up @@ -169,10 +167,7 @@ describe("test contract", () => {
caller: alice.address,
});

provider.mockUpdateAccount(alice.address, (account) => {
account.nonce = 42n;
});

alice.nonce = 42n;
deployTransaction.nonce = alice.nonce;

assert.equal(deployTransaction.data.toString(), "upgradeContract@01020304@0100");
Expand Down
2 changes: 1 addition & 1 deletion src/accounts/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("test account methods", function () {
});

it("should create account from keystore", async function () {
const account = Account.newFromKeystore(`${testWallets}/withDummyMnemonic.json`, "password");
const account = Account.newFromKeystore(`${getTestWalletsPath()}/withDummyMnemonic.json`, "password");

assert.equal(
account.secretKey.valueOf().toString("hex"),
Expand Down
15 changes: 7 additions & 8 deletions src/core/transaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ describe("test transaction", async () => {
it("should sign transaction (with usernames)", async () => {
const transaction = new Transaction({
chainID: "T",
sender: alice.address,
receiver: bob.address,
sender: carol.address,
receiver: alice.address,
gasLimit: 50000n,
value: 1000000000000000000n,
version: 2,
Expand All @@ -133,7 +133,7 @@ describe("test transaction", async () => {
receiverUsername: "alice",
});

transaction.signature = alice.signTransaction(transaction);
transaction.signature = carol.signTransaction(transaction);

assert.equal(
Buffer.from(transaction.signature).toString("hex"),
Expand Down Expand Up @@ -343,7 +343,7 @@ describe("test transaction", async () => {
chainID: "T",
});

transaction.signature = alice.signTransaction(transaction);
transaction.signature = carol.signTransaction(transaction);

assert.equal(
Buffer.from(transaction.signature).toString("hex"),
Expand Down Expand Up @@ -608,7 +608,7 @@ describe("test transaction", async () => {
options: 1,
});

transaction.signature = alice.signTransaction(transaction);
transaction.signature = await alice.sign(transactionComputer.computeHashForSigning(transaction));

assert.equal(
Buffer.from(transaction.signature).toString("hex"),
Expand Down Expand Up @@ -719,9 +719,9 @@ describe("test transaction", async () => {

transactionComputer.applyOptionsForHashSigning(transaction);

transaction.signature = alice.signTransaction(transaction);
transaction.signature = await alice.sign(transactionComputer.computeHashForSigning(transaction));

const userVerifier = new UserVerifier(new UserPublicKey(alice.address.getPublicKey()));
const userVerifier = new UserVerifier(alice.publicKey);
const isSignedByAlice = userVerifier.verify(
transactionComputer.computeBytesForVerifying(transaction),
transaction.signature,
Expand All @@ -732,7 +732,6 @@ describe("test transaction", async () => {
transactionComputer.computeBytesForVerifying(transaction),
transaction.signature,
);

assert.equal(isSignedByAlice, true);
assert.equal(isSignedByBob, false);
});
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/userKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class UserSecretKey {
return new UserSecretKey(secretKey);
}

sign(message: Buffer | Uint8Array): Uint8Array {
sign(message: Uint8Array): Uint8Array {
const signature = ed.sync.sign(new Uint8Array(message), new Uint8Array(this.buffer));
return signature;
}
Expand Down

0 comments on commit ff2520e

Please sign in to comment.