Merge pull request #553 from embark-framework/chores/update-templates

Update templates with tests and comments
This commit is contained in:
Iuri Matias 2018-06-18 16:35:16 -04:00 committed by GitHub
commit c5799839bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 227 additions and 145 deletions

View File

@ -1,28 +1,31 @@
module.exports = { module.exports = {
development: { development: {
enabled: true, enabled: true,
networkType: "custom", networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: "1337", networkId: "1337", // Network id used when networkType is custom
isDev: true, isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
genesisBlock: "config/development/genesis.json", genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
datadir: ".embark/development/datadir", datadir: ".embark/development/datadir", // Data directory for the databases and keystore
mineWhenNeeded: true, mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
rpcHost: "localhost", rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: "auto", rpcCorsDomain: "auto", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
proxy: true, // When set to "auto", Embark will automatically set the cors to the address of the webserver
proxy: true, // Proxy is used to present meaningful information about transactions
account: { account: {
password: "config/development/password" // "address": "", // When specified, uses that address instead of the default one for the network
password: "config/development/password" // Password to unlock the account
}, },
targetGasLimit: 8000000, targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
wsOrigins: "auto", wsRPC: true, // Enable the WS-RPC server
wsRPC: true, wsOrigins: "auto", // Origins from which to accept websockets requests
wsHost: "localhost", // When set to "auto", Embark will automatically set the cors to the address of the webserver
wsPort: 8546, wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", wsPort: 8546, // WS-RPC server listening port (default: 8546)
simulatorBlocktime: 0 simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
}, },
testnet: { testnet: {
enabled: true, enabled: true,
@ -56,4 +59,4 @@ module.exports = {
networkId: "123", networkId: "123",
bootnodes: "" bootnodes: ""
} }
} };

View File

@ -1,13 +1,13 @@
module.exports = { module.exports = {
default: { default: {
enabled: true, enabled: true,
provider: "whisper", provider: "whisper", // Communication provider. Currently, Embark only supports whisper
available_providers: ["whisper"], available_providers: ["whisper"], // Array of available providers
connection: { connection: {
host: "localhost", host: "localhost", // Host of the blockchain node
port: 8546, port: 8546, // Port of the blockchain node
type: "ws" type: "ws" // Type of connection (ws or rpc)
} }
} }
} };

View File

@ -1,11 +1,28 @@
module.exports = { module.exports = {
// default applies to all enviroments // default applies to all environments
default: { default: {
// rpc to deploy the contracts // Blockchain node to deploy the contracts
deployment: { deployment: {
host: "localhost", host: "localhost", // Host of the blockchain node
port: 8545, port: 8545, // Port of the blockchain node
type: "rpc" type: "rpc" // Type of connection (ws or rpc),
// Accounts to use instead of the default account to populate your wallet
/*,accounts: [
{
privateKey: "your_private_key",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
},
{
privateKeyFile: "path/to/file" // You can put more than one key, separated by , or ;
},
{
mnemonic: "12 word mnemonic",
addressIndex: "0", // Optionnal. The index to start getting the address
numAddresses: "1", // Optionnal. The number of addresses to get
hdpath: "m/44'/60'/0'/0/" // Optionnal. HD derivation path
}
]*/
}, },
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
@ -21,4 +38,4 @@ module.exports = {
//} //}
} }
} }
} };

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
default: { default: {
available_providers: ["ens"], available_providers: ["ens"],
provider: "ens" provider: "ens"
} }
} };

View File

@ -9,8 +9,19 @@ module.exports = {
port: 5001 port: 5001
}, },
dappConnection: [ dappConnection: [
{provider: "ipfs", host: "localhost", port: 5001, getUrl: "http://localhost:8080/ipfs/"} {
provider: "ipfs",
host: "localhost",
port: 5001,
getUrl: "http://localhost:8080/ipfs/"
}
] ]
// Configuration to start Swarm in the same terminal as `embark run`
/*,account: {
address: "YOUR_ACCOUNT_ADDRESS", // Address of account accessing Swarm
password: "PATH/TO/PASSWORD/FILE" // File containing the password of the account
},
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
}, },
development: { development: {
enabled: true, enabled: true,
@ -21,4 +32,4 @@ module.exports = {
getUrl: "http://localhost:8080/ipfs/" getUrl: "http://localhost:8080/ipfs/"
} }
} }
} };

View File

@ -2,4 +2,4 @@ module.exports = {
enabled: true, enabled: true,
host: "localhost", host: "localhost",
port: 8000 port: 8000
} };

View File

@ -1,24 +1,25 @@
//describe("SimpleStorage", function() { // /*global contract, config, it, assert*/
// this.timeout(0); /*const SimpleStorage = require('Embark/contracts/SimpleStorage');
// before(function(done) {
// this.timeout(0); config({
// var contractsConfig = { contracts: {
// "SimpleStorage": { "SimpleStorage": {
// args: [100] args: [100]
// } }
// }; }
// EmbarkSpec.deployAll(contractsConfig, () => { done() }); });
// });
// contract("SimpleStorage", function () {
// it("should set constructor value", async function() { this.timeout(0);
// let result = await SimpleStorage.methods.storedData().call();
// assert.equal(result, 100); it("should set constructor value", async function () {
// }); let result = await SimpleStorage.methods.storedData().call();
// assert.strictEqual(parseInt(result, 10), 100);
// it("set storage value", async function() { });
// await SimpleStorage.methods.set(150).send();
// let result = await SimpleStorage.methods.get().call(); it("set storage value", async function () {
// assert.equal(result, 150); await SimpleStorage.methods.set(150).send();
// }); let result = await SimpleStorage.methods.get().call();
// assert.strictEqual(parseInt(result, 10), 150);
//}); });
});*/

View File

@ -1,28 +1,31 @@
module.exports = { module.exports = {
development: { development: {
enabled: true, enabled: true,
networkType: "custom", networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
networkId: "1337", networkId: "1337", // Network id used when networkType is custom
isDev: true, isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
genesisBlock: "config/development/genesis.json", genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
datadir: ".embark/development/datadir", datadir: ".embark/development/datadir", // Data directory for the databases and keystore
mineWhenNeeded: true, mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
nodiscover: true, nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
maxpeers: 0, maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
rpcHost: "localhost", rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
rpcPort: 8545, rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
rpcCorsDomain: "auto", rpcCorsDomain: "auto", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
proxy: true, // When set to "auto", Embark will automatically set the cors to the address of the webserver
proxy: true, // Proxy is used to present meaningful information about transactions
account: { account: {
password: "config/development/password" // "address": "", // When specified, uses that address instead of the default one for the network
password: "config/development/password" // Password to unlock the account
}, },
targetGasLimit: 8000000, targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
wsOrigins: "auto", wsRPC: true, // Enable the WS-RPC server
wsRPC: true, wsOrigins: "auto", // Origins from which to accept websockets requests
wsHost: "localhost", // When set to "auto", Embark will automatically set the cors to the address of the webserver
wsPort: 8546, wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", wsPort: 8546, // WS-RPC server listening port (default: 8546)
simulatorBlocktime: 0 simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
}, },
testnet: { testnet: {
enabled: true, enabled: true,
@ -56,4 +59,4 @@ module.exports = {
networkId: "123", networkId: "123",
bootnodes: "" bootnodes: ""
} }
} };

View File

@ -1,12 +1,12 @@
module.exports = { module.exports = {
default: { default: {
enabled: true, enabled: true,
provider: "whisper", provider: "whisper", // Communication provider. Currently, Embark only supports whisper
available_providers: ["whisper"], available_providers: ["whisper"], // Array of available providers
connection: { connection: {
host: "localhost", host: "localhost", // Host of the blockchain node
port: 8546, port: 8546, // Port of the blockchain node
type: "ws" type: "ws" // Type of connection (ws or rpc)
} }
} }
} };

View File

@ -1,11 +1,28 @@
module.exports = { module.exports = {
// default applies to all enviroments // default applies to all environments
default: { default: {
// rpc to deploy the contracts // Blockchain node to deploy the contracts
deployment: { deployment: {
host: "localhost", host: "localhost", // Host of the blockchain node
port: 8545, port: 8545, // Port of the blockchain node
type: "rpc" type: "rpc" // Type of connection (ws or rpc),
// Accounts to use instead of the default account to populate your wallet
/*,accounts: [
{
privateKey: "your_private_key",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
},
{
privateKeyFile: "path/to/file" // You can put more than one key, separated by , or ;
},
{
mnemonic: "12 word mnemonic",
addressIndex: "0", // Optionnal. The index to start getting the address
numAddresses: "1", // Optionnal. The number of addresses to get
hdpath: "m/44'/60'/0'/0/" // Optionnal. HD derivation path
}
]*/
}, },
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
@ -17,8 +34,8 @@ module.exports = {
contracts: { contracts: {
SimpleStorage: { SimpleStorage: {
fromIndex: 0, fromIndex: 0,
args: [ 100 ] args: [100]
} }
} }
} }
} };

View File

@ -3,4 +3,4 @@ module.exports = {
available_providers: ["ens"], available_providers: ["ens"],
provider: "ens" provider: "ens"
} }
} };

View File

@ -9,8 +9,19 @@ module.exports = {
port: 5001 port: 5001
}, },
dappConnection: [ dappConnection: [
{provider: "ipfs", host: "localhost", port: 5001, getUrl: "http://localhost:8080/ipfs/"} {
provider:"ipfs",
host: "localhost",
port: 5001,
getUrl: "http://localhost:8080/ipfs/"
}
] ]
// Configuration to start Swarm in the same terminal as `embark run`
/*,account: {
address: "YOUR_ACCOUNT_ADDRESS", // Address of account accessing Swarm
password: "PATH/TO/PASSWORD/FILE" // File containing the password of the account
},
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
}, },
development: { development: {
enabled: true, enabled: true,
@ -21,4 +32,4 @@ module.exports = {
getUrl: "http://localhost:8080/ipfs/" getUrl: "http://localhost:8080/ipfs/"
} }
} }
} };

View File

@ -2,4 +2,4 @@ module.exports = {
enabled: true, enabled: true,
host: "localhost", host: "localhost",
port: 8000 port: 8000
} };

View File

@ -1,24 +1,25 @@
describe("SimpleStorage", function() { /*global contract, config, it, assert*/
const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({
contracts: {
"SimpleStorage": {
args: [100]
}
}
});
contract("SimpleStorage", function () {
this.timeout(0); this.timeout(0);
before(function(done) {
this.timeout(0);
var contractsConfig = {
"SimpleStorage": {
args: [100]
}
};
EmbarkSpec.deployAll(contractsConfig, () => { done() });
});
it("should set constructor value", async function() { it("should set constructor value", async function () {
let result = await SimpleStorage.methods.storedData().call(); let result = await SimpleStorage.methods.storedData().call();
assert.equal(result, 100); assert.strictEqual(parseInt(result, 10), 100);
}); });
it("set storage value", async function() { it("set storage value", async function () {
await SimpleStorage.methods.set(150).send(); await SimpleStorage.methods.set(150).send();
let result = await SimpleStorage.methods.get().call(); let result = await SimpleStorage.methods.get().call();
assert.equal(result, 150); assert.strictEqual(parseInt(result, 10), 150);
}); });
}); });

View File

@ -1,11 +1,28 @@
module.exports = { module.exports = {
// default applies to all enviroments // default applies to all environments
default: { default: {
// rpc to deploy the contracts // Blockchain node to deploy the contracts
deployment: { deployment: {
host: "localhost", host: "localhost", // Host of the blockchain node
port: 8545, port: 8545, // Port of the blockchain node
type: "rpc" type: "rpc" // Type of connection (ws or rpc),
// Accounts to use instead of the default account to populate your wallet
/*,accounts: [
{
privateKey: "your_private_key",
balance: "5 ether" // You can set the balance of the account in the dev environment
// Balances are in Wei, but you can specify the unit with its name
},
{
privateKeyFile: "path/to/file" // You can put more than one key, separated by , or ;
},
{
mnemonic: "12 word mnemonic",
addressIndex: "0", // Optionnal. The index to start getting the address
numAddresses: "1", // Optionnal. The number of addresses to get
hdpath: "m/44'/60'/0'/0/" // Optionnal. HD derivation path
}
]*/
}, },
// order of connections the dapp should connect to // order of connections the dapp should connect to
dappConnection: [ dappConnection: [
@ -21,4 +38,4 @@ module.exports = {
//} //}
} }
} }
} };

View File

@ -1,24 +1,25 @@
//describe("SimpleStorage", function() { // /*global contract, config, it, assert*/
// this.timeout(0); /*const SimpleStorage = require('Embark/contracts/SimpleStorage');
// before(function(done) {
// this.timeout(0); config({
// var contractsConfig = { contracts: {
// "SimpleStorage": { "SimpleStorage": {
// args: [100] args: [100]
// } }
// }; }
// EmbarkSpec.deployAll(contractsConfig, () => { done() }); });
// });
// contract("SimpleStorage", function () {
// it("should set constructor value", async function() { this.timeout(0);
// let result = await SimpleStorage.methods.storedData().call();
// assert.equal(result, 100); it("should set constructor value", async function () {
// }); let result = await SimpleStorage.methods.storedData().call();
// assert.strictEqual(parseInt(result, 10), 100);
// it("set storage value", async function() { });
// await SimpleStorage.methods.set(150).send();
// let result = await SimpleStorage.methods.get().call(); it("set storage value", async function () {
// assert.equal(result, 150); await SimpleStorage.methods.set(150).send();
// }); let result = await SimpleStorage.methods.get().call();
// assert.strictEqual(parseInt(result, 10), 150);
//}); });
});*/