Skip to content

Commit 611e91c

Browse files
committed
Make the server URL in the tests configurable
1 parent e6e9eb3 commit 611e91c

16 files changed

+61
-19
lines changed

examples/create-account-with-keystore.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
var SDK = require("codechain-sdk");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
// createRemoteKeyStore("http://localhost:7007") is also available.
69
// If you want to know how to set up the external key store, go to
710
// https://codechain.readthedocs.io/en/latest/asset-management.html#use-remotekeystore-to-save-asset-address-private-key
811
sdk.key
912
.createLocalKeyStore()
1013
.then(function(keyStore) {
11-
return sdk.key.createPlatformAddress({ keyStore });
14+
return sdk.key.createPlatformAddress({
15+
keyStore
16+
});
1217
})
1318
.then(function(address) {
1419
console.log(address.toString());

examples/create-account-with-rpc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var SDK = require("codechain-sdk");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
sdk.rpc.account
69
.create("my-secret")

examples/create-asset-transfer-address.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var SDK = require("codechain-sdk");
2+
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
24
var sdk = new SDK({
3-
server: "http://localhost:8080"
5+
server: SERVER_URL
46
});
57

68
sdk.key

examples/get-balance.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var SDK = require("codechain-sdk");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
sdk.rpc.chain
69
.getBalance("tccqzn9jjm3j6qg69smd7cn0eup4w7z2yu9my9a2k78")

examples/import-test-account.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var SDK = require("codechain-sdk");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
var secret = "ede1d4ccb4ec9a8bbbae9a13db3f4a7b56ea04189be86ac3a6a439d9a0a1addd";
69
var passphrase = "satoshi";

examples/mint-and-burn.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const SDK = require("codechain-sdk");
22

3+
const SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
34
const sdk = new SDK({
4-
server: "http://localhost:8080"
5+
server: SERVER_URL
56
});
67

78
(async () => {

examples/mint-and-transfer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const SDK = require("codechain-sdk");
22

3+
const SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
34
const sdk = new SDK({
4-
server: "http://localhost:8080"
5+
server: SERVER_URL
56
});
67

78
(async () => {

examples/mint-asset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var SDK = require("codechain-sdk");
22

3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
34
var sdk = new SDK({
4-
server: "http://localhost:8080"
5+
server: SERVER_URL
56
});
67

78
// If you want to know how to create an address, see the example "Create an

examples/send-parcel.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var SDK = require("codechain-sdk");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
var parcel = sdk.core.createPaymentParcel({
69
recipient: "tccqruq09sfgax77nj4gukjcuq69uzeyv0jcs7vzngg",

examples/send-signed-parcel-with-keystore.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var SDK = require("..");
22

3-
var sdk = new SDK({ server: "http://localhost:8080" });
3+
var SERVER_URL = process.env.CODECHAIN_RPC_HTTP || "http://localhost:8080";
4+
var sdk = new SDK({
5+
server: SERVER_URL
6+
});
47

58
var parcel = sdk.core.createPaymentParcel({
69
recipient: "tccqruq09sfgax77nj4gukjcuq69uzeyv0jcs7vzngg",
@@ -9,7 +12,9 @@ var parcel = sdk.core.createPaymentParcel({
912

1013
(async () => {
1114
const keyStore = await sdk.key.createLocalKeyStore();
12-
const account = await sdk.key.createPlatformAddress({ keyStore });
15+
const account = await sdk.key.createPlatformAddress({
16+
keyStore
17+
});
1318
const nonce = await sdk.rpc.chain.getNonce(account);
1419

1520
const signedParcel = await sdk.key.signParcel(parcel, {

0 commit comments

Comments
 (0)