Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions tests/src/kinClient.intg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import {TransactionBuilder} from "../../scripts/src/blockchain/transactionBuilde
import {INTEG_ENV} from "./integConfig";

const keypair = KeyPair.generate();
const seconedKeypair = KeyPair.generate();
const seconedKeyPair = KeyPair.generate();
let client: KinClient;
let sender: KinAccount;
let receiver: KinAccount;

describe("KinClient", async () => {
beforeAll(async () => {
client = new KinClient(INTEG_ENV);
sender = client.createKinAccount({ seed: keypair.seed });
receiver = client.createKinAccount({ seed: seconedKeypair.seed });
const transactionId = await client.friendbot({ address: keypair.publicAddress, amount: 10000 });
const secondtransactionId = await client.friendbot({ address: seconedKeypair.publicAddress, amount: 10000 });
sender = client.createKinAccount({seed: keypair.seed});
receiver = client.createKinAccount({seed: seconedKeyPair.seed});
const transactionId = await client.friendbot({address: keypair.publicAddress, amount: 10000});
const secondTransactionId = await client.friendbot({address: seconedKeyPair.publicAddress, amount: 10000});
expect(transactionId).toBeDefined();
expect(secondtransactionId).toBeDefined();
expect(secondTransactionId).toBeDefined();
}, 30000);

test("Create sender with friend bot", async () => {
Expand All @@ -37,9 +37,9 @@ describe("KinClient", async () => {
expect(data.signers[0].publicKey).toBe(keypair.publicAddress);
expect(data.id).toBe(keypair.publicAddress);

const thirdKeypair = KeyPair.generate();
const getDataKeyPair = KeyPair.generate();
const builder = await sender.buildCreateAccount({
address: thirdKeypair.publicAddress,
address: getDataKeyPair.publicAddress,
fee: 100,
startingBalance: 1000,
memoText: "my first wallet"
Expand All @@ -55,60 +55,60 @@ describe("KinClient", async () => {
}, 60000);

test("Test getTransactionData", async () => {
const thirdKeypair = KeyPair.generate();
const getTxKeyPair = KeyPair.generate();
const builder = await sender.buildCreateAccount({
address: thirdKeypair.publicAddress,
address: getTxKeyPair.publicAddress,
fee: 100,
startingBalance: 1000,
memoText: "my first wallet"
});

const transactionId = await sender.submitTransaction(builder);
const data = await client.getTransactionData(transactionId);
expect((data as any).destination).toBe(thirdKeypair.publicAddress);
expect((data as any).destination).toBe(getTxKeyPair.publicAddress);
expect((data as any).startingBalance).toBe(1000);
expect(data.source).toBe(sender.publicAddress);
expect(data.memo).toBe("1-anon-my first wallet");
}, 30000);

test("Test get transaction history", async () => {
const thirdKeypair = KeyPair.generate();
await client.friendbot({ address: thirdKeypair.publicAddress, amount: 1000 });
const historyKeyPair = KeyPair.generate();
await client.friendbot({address: historyKeyPair.publicAddress, amount: 1000});

let sendBuilder: TransactionBuilder;
for (let i = 0; i < 2; i++) {
sendBuilder = await sender.buildSendKin({
address: thirdKeypair.publicAddress,
address: historyKeyPair.publicAddress,
amount: 10,
fee: 100,
memoText: "sending kin: " + i
});
await sender.submitTransaction(sendBuilder);
}

const history = await client.getTransactionHistory({ address: thirdKeypair.publicAddress });
const history = await client.getTransactionHistory({address: historyKeyPair.publicAddress});
expect(history.length).toBe(3);
expect(history[0].memo).toBe("1-anon-sending kin: 1");
expect(history[1].memo).toBe("1-anon-sending kin: 0");
expect((history[2] as any).startingBalance).toBe(1000);
}, 60000);

test("Test getBalance", async () => {
const thirdKeypair = KeyPair.generate();
await client.friendbot({ address: thirdKeypair.publicAddress, amount: 1000 });
const balanceKeyPair = KeyPair.generate();
await client.friendbot({address: balanceKeyPair.publicAddress, amount: 1000});

let sendBuilder: TransactionBuilder;
for (let i = 0; i < 2; i++) {
sendBuilder = await sender.buildSendKin({
address: thirdKeypair.publicAddress,
address: balanceKeyPair.publicAddress,
amount: 10,
fee: 100,
memoText: "sending kin: " + i
});
await sender.submitTransaction(sendBuilder);
}

const balance = await client.getAccountBalance(thirdKeypair.publicAddress);
const balance = await client.getAccountBalance(balanceKeyPair.publicAddress);
expect(balance).toBe(1020);
}, 60000);

Expand All @@ -117,7 +117,7 @@ describe("KinClient", async () => {
await client.createPaymentListener({
addresses: [receiver.publicAddress], onPayment: payment => {
expect(payment.source).toBe(keypair.publicAddress);
expect(payment.destination).toBe(seconedKeypair.publicAddress);
expect(payment.destination).toBe(seconedKeyPair.publicAddress);
expect(payment.memo).toBe("1-anon-sending kin");
expect(payment.amount).toBe(10);
expect(payment.hash).toBe(hash);
Expand Down