Skip to content

Commit

Permalink
finish getting tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
BlaineHeffron committed Jun 27, 2024
1 parent 30e1fcd commit e7c024e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
2 changes: 1 addition & 1 deletion test/e2e/src/test-contract-client-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("Client", function () {

it("can be constructed with `new Client`", async function() {
const { result } = await this.context.client.hello({ to: "tests" });
expect(result).to.equal("tests");
expect(result).to.deep.equal(["Hello", "tests"]);
});

it("can be constructed with `from`", async function () {
Expand Down
33 changes: 28 additions & 5 deletions test/e2e/src/test-custom-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,42 @@ describe("Custom Types Tests", function () {
});

it("view method with empty keypair", async function() {
const { client: client2 } = await clientFor("helloWorld", {
const { client: client2 } = await clientFor("customTypes", {
keypair: undefined,
contractId: this.context.contractId,
contractId: this.context.contractId
});
expect((await client2.hello({ hello: "anonymous" })).result).to.equal(
"anonymous",
);
expect((await client2.i32_({ i32_: 1 })).result).to.equal(1);
});

it("should increment the counter correctly", async function() {
const { result: startingBalance } = await this.context.client.get_count();
const inc = await this.context.client.inc();
const incrementResponse = await inc.signAndSend();
expect(incrementResponse.result).to.equal(startingBalance + 1);
expect(startingBalance).to.equal(0); // Assuming the counter starts at 0
const { result: newBalance } = await this.context.client.get_count();
expect(newBalance).to.equal(startingBalance + 1);
});

it("should accept only options object for methods with no arguments", async function() {
const inc = await this.context.client.inc({ simulate: false });
expect(inc.simulation).to.be.undefined;
});

it("woid", async function () {
expect((await this.context.client.woid()).result).to.be.null;
});

it("should authenticate the user correctly", async function() {
const { result } = await this.context.client.auth({ addr: this.context.publicKey, world: "lol" });
expect(result).to.equal(this.context.publicKey);
});

it("should authenticate the user correctly", async function() {
const { result } = await this.context.client.auth({ addr: this.context.publicKey, world: "lol" });
expect(result).to.equal(this.context.publicKey);
});

it("u32_fail_on_even", async function () {
let response = await this.context.client.u32_fail_on_even({ u32_: 1 });
expect(response.result).to.deep.equal(new contract.Ok(1));
Expand Down
34 changes: 0 additions & 34 deletions test/e2e/src/test-hello-world.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/src/test-methods-as-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function callMethod(method, args) {
describe("methods-as-args", function () {
it("should pass methods as arguments and have them still work", async function () {
const { client } = await clientFor("helloWorld");
const { result } = await callMethod(client.hello, { world: "tests" });
const { result } = await callMethod(client.hello, { to: "tests" });
expect(result).to.deep.equal(["Hello", "tests"]);
});
});
2 changes: 1 addition & 1 deletion test/e2e/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports.friendbotUrl = friendbotUrl;

async function generateFundedKeypair() {
const keypair = Keypair.random();
await fetch(`${friendbotUrl}/?addr=${keypair.publicKey()}`);
await fetch(friendbotUrl.indexOf('friendbot.stellar.org') !== -1 ? `${friendbotUrl}/?addr=${keypair.publicKey()}` : `${friendbotUrl}/friendbot?addr=${keypair.publicKey()}`);
return keypair;
}
module.exports.generateFundedKeypair = generateFundedKeypair;
Expand Down

0 comments on commit e7c024e

Please sign in to comment.