Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
Use test helpers for wallet creation in ownership tests
Browse files Browse the repository at this point in the history
This should fix these tests when run against long-running test networks
(as we now do in integration tests & CI).
  • Loading branch information
cap10morgan committed May 17, 2019
1 parent 6d7bd4b commit c8a6d0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 37 deletions.
1 change: 0 additions & 1 deletion test/data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const helpers = require("./helpers");
const assert = require("assert");
const Tagged = require("cbor/lib/tagged");
const Tupelo = require("../lib/tupelo");
const itRequires = helpers.itRequires

describe("setting and retrieving data", function() {
Expand Down
42 changes: 6 additions & 36 deletions test/ownership.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
const assert = require("assert");
const Tupelo = require("../lib/tupelo");
const TUPELO_HOST = process.env.TUPELO_RPC_HOST || 'localhost:50051'
const helpers = require("./helpers");

// TODO: Remove the "oldResult" tests once resolveData support is released.

describe("ownership transfer", function () {
this.timeout(30000);

it("can export and import", async () => {
const alice = Tupelo.connect(TUPELO_HOST, {
walletName: "alice-test",
passPhrase: "test",
});
// TODO: clear RPC server state between tests automatically
await alice.register();
const {keyAddr: aliceKey,} = await alice.generateKey();
const {chainId,} = await alice.createChainTree(aliceKey);

const bob = Tupelo.connect(TUPELO_HOST, {
walletName: "bob-test",
passPhrase: "test",
});
// TODO: clear RPC server state between tests automatically
await bob.register();
const {keyAddr: bobKey,} = await bob.generateKey();
assert.strictEqual(bobKey.length, 42);

let {wallet: alice, walletKey: aliceKey, chainId: chainId} = await helpers.createWalletWithChain();
let {wallet: bob, walletKey: bobKey, chainId: bobChainId} = await helpers.createWalletWithChain();

let resp = await alice.setData(chainId, aliceKey, "path/to/here", "hi");
assert.notEqual(resp.tip, null);

Expand All @@ -41,22 +25,8 @@ describe("ownership transfer", function () {
});

it("can do a real transfer from alice to bob", async () => {
const alice = Tupelo.connect(TUPELO_HOST, {
walletName: "alice-test",
passPhrase: "test",
});
// TODO: clear RPC server state between tests automatically
// await alice.register();
const {keyAddr: aliceKey,} = await alice.generateKey();
let {chainId,} = await alice.createChainTree(aliceKey);

const bob = Tupelo.connect(TUPELO_HOST, {
walletName: "bob-test",
passPhrase: "test",
});
// TODO: clear RPC server state between tests automatically
// await bob.register();
const {keyAddr: bobKey,} = await bob.generateKey();
let {wallet: alice, walletKey: aliceKey, chainId: chainId} = await helpers.createWalletWithChain();
let {wallet: bob, walletKey: bobKey, chainId: bobChainId} = await helpers.createWalletWithChain();

for (let i = 0; i < 5; i++) {
const resp = await alice.setData(chainId, aliceKey, "path/to/" + i.toString(),
Expand Down

0 comments on commit c8a6d0a

Please sign in to comment.