Skip to content

Commit e5ad986

Browse files
committed
add tests for 2 dimensional arrays
1 parent 42a38ef commit e5ad986

File tree

15 files changed

+4012
-0
lines changed

15 files changed

+4012
-0
lines changed

etherspace-java/contract/.gitignore

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
pragma solidity ^0.4.2;
2+
3+
// Modified Greeter contract. Based on example at https://www.ethereum.org/greeter.
4+
5+
contract mortal {
6+
/* Define variable owner of the type address*/
7+
address owner;
8+
9+
/* this function is executed at initialization and sets the owner of the contract */
10+
function mortal() { owner = msg.sender; }
11+
12+
/* Function to recover the funds on the contract */
13+
function kill() { if (msg.sender == owner) suicide(owner); }
14+
}
15+
16+
contract greeter is mortal {
17+
/* define variable greeting of the type string */
18+
string greeting;
19+
20+
/* this runs when the contract is executed */
21+
function greeter(string _greeting) public {
22+
greeting = _greeting;
23+
}
24+
25+
function newGreeting(string _greeting) public {
26+
Modified(greeting, _greeting, greeting, _greeting);
27+
greeting = _greeting;
28+
}
29+
30+
function twoDimensionArray(uint[5][] array, uint row, uint col) constant returns (uint) {
31+
return array[row][col];
32+
}
33+
34+
/* main function */
35+
function greet() constant returns (string) {
36+
return greeting;
37+
}
38+
39+
/* we include indexed events to demonstrate the difference that can be
40+
captured versus non-indexed */
41+
event Modified(
42+
string indexed oldGreetingIdx, string indexed newGreetingIdx,
43+
string oldGreeting, string newGreeting);
44+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.4.2;
2+
3+
contract Migrations {
4+
address public owner;
5+
uint public last_completed_migration;
6+
7+
modifier restricted() {
8+
if (msg.sender == owner) _;
9+
}
10+
11+
constructor() public {
12+
owner = msg.sender;
13+
}
14+
15+
function setCompleted(uint completed) public restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
rm -rf build/contracts
3+
truffle migration --network development
4+
cp -R build/contracts ../build/

etherspace-java/contract/deploy.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$1" ]; then
4+
echo "Please input network (development/kovan/mainnet)!"
5+
exit 1
6+
fi
7+
8+
if [ -z "$2" ]; then
9+
echo "Please input mnemonic!"
10+
exit 1
11+
fi
12+
13+
export MNEMONIC=$2
14+
15+
GIT_HASH="$(git log --pretty=format:'%h' -n 1)"
16+
echo 'Git Hash: '$GIT_HASH
17+
18+
echo 'truffle migration...'
19+
truffle migration --network $1 -f 1 --to 2
20+
21+
if [ "$?" != 0 ]; then
22+
echo 'Deploy error'
23+
exit 2
24+
fi
25+
26+
echo 'Done ...'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Migrations = artifacts.require("./Migrations.sol");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Migrations);
5+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Greeter = artifacts.require("../contracts/Greeter.sol");
2+
3+
module.exports = function (deployer) {
4+
deployer.deploy(Greeter, "Hello World");
5+
};

0 commit comments

Comments
 (0)