Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit a90459d

Browse files
author
Maksim Daunarovich
authored
Quickfix/config path update (#42)
* Fix flow.json path to private key on service account * Bump version * Refactor init usage with new props * Update flow.json file * Ensure that fallback value is used * Pass additional values as object
1 parent 15cec5c commit a90459d

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

dev-test/interaction.test.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from "path";
2-
import * as types from "@onflow/types"
2+
import * as types from "@onflow/types";
33
import {
44
emulator,
55
init,
@@ -18,7 +18,7 @@ describe("interactions - sendTransaction", () => {
1818
beforeEach(async () => {
1919
const basePath = path.resolve(__dirname, "./cadence");
2020
const port = 8080;
21-
await init(basePath, port);
21+
await init(basePath, { port });
2222
return emulator.start(port, false);
2323
});
2424

@@ -68,9 +68,7 @@ describe("interactions - sendTransaction", () => {
6868
}
6969
}
7070
`;
71-
const args = [
72-
[42, types.Int]
73-
]
71+
const args = [[42, types.Int]];
7472
return sendTransaction({ code, args });
7573
});
7674
});
@@ -85,8 +83,8 @@ describe("interactions - sendTransaction", () => {
8583
`;
8684
const args = [
8785
[42, 1337, types.Int],
88-
["Hello, Cadence", types.String]
89-
]
86+
["Hello, Cadence", types.String],
87+
];
9088
return sendTransaction({ code, args });
9189
});
9290
});
@@ -99,7 +97,7 @@ describe("interactions - sendTransaction", () => {
9997
}
10098
}
10199
`;
102-
const args = [ 42, 1337, "Hello, Cadence"]
100+
const args = [42, 1337, "Hello, Cadence"];
103101

104102
return sendTransaction({ code, args });
105103
});
@@ -110,7 +108,7 @@ describe("interactions - executeScript", () => {
110108
beforeEach(async () => {
111109
const basePath = path.resolve(__dirname, "./cadence");
112110
const port = 8080;
113-
await init(basePath, port);
111+
await init(basePath, { port });
114112
return emulator.start(port, false);
115113
});
116114

flow.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"accounts": {
1515
"emulator-account": {
1616
"address": "f8d6e0586b0a20c7",
17-
"keys": "48a1f554aeebf6bf9fe0d7b5139b79d080700b073ee77909973ea0b2f6fbc902"
17+
"key": "f9cd76bf71c3371c76743ff22a0a1ee6657c63c46c62bd86a20266471fe0ea70"
1818
}
1919
},
2020
"deployments": {}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flow-js-testing",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"description": "This package will expose a set of utility methods, to allow Cadence code testing with libraries like Jest",
55
"scripts": {
66
"build": "microbundle",

src/config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export const get = (scope, path, fallback) => {
4545
* @param fallback - fallback value to be used if env and conf are absent.
4646
*/
4747
export const set = (key, env, conf, fallback) => {
48-
config().put(key, env || get(flowConfig(), conf, fallback));
48+
let value = get(flowConfig(), conf, fallback);
49+
if (!value) {
50+
value = fallback;
51+
}
52+
config().put(key, value);
4953
};
5054

5155
/**

src/init.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ import { config } from "@onflow/config";
2323
* Inits framework variables, storing private key of service account and base path
2424
* where Cadence files are stored.
2525
* @param {string} basePath - path to the folder with Cadence files to be tested.
26-
* @param {number} port - port to use for accessAPI
26+
* @param {number} [props.port] - port to use for accessAPI
27+
* @param {number} [props.pkey] - private key to use for service account in case of collisions
2728
*/
28-
export const init = async (basePath, port = 8080) => {
29-
set("PRIVATE_KEY", process.env.PK, "accounts/emulator-account/keys");
29+
export const init = async (basePath, props = {}) => {
30+
const { port = 8080 } = props;
31+
const { pkey = "48a1f554aeebf6bf9fe0d7b5b79d080700b073ee77909973ea0b2f6fbc902" } = props;
32+
33+
set("PRIVATE_KEY", process.env.PK, "accounts/emulator-account/key", pkey);
3034
set(
3135
"SERVICE_ADDRESS",
3236
process.env.SERVICE_ADDRESS,

0 commit comments

Comments
 (0)