-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgreeter.js
More file actions
51 lines (47 loc) · 2.01 KB
/
greeter.js
File metadata and controls
51 lines (47 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var Greeter = artifacts.require("./Greeter.sol");
contract('Greeter',
function()
{
it("Should say that no greeting has been yet provided",
function()
{
return
Greeter.deployed()
.then(function(instance)
{
return instance.greet.call();
})
.then(function(greeting)
{
assert.equal(greeting.valueOf(), "noGreetSentenceProvided", "A greeting sentence has been provided");
});
});
it("Should set a greeting sentence, retrieve it",
function()
{
//Contract instance
var meta;
// Greeting to set
var greeting = "Hello Dolly";
return Greeter.deployed()
.then(function(instance)
{
console.log("Set new greeting sentence");
meta = instance;
meta.setGreeting(greeting,{from: web3.eth.accounts[0],gas: 4000000});
})
.then(function()
{
console.log("Requesting greet");
retGreet = meta.greet();
return retGreet;
})
.then(function(retGreet)
{
console.log("Testing returned greet sentence");
assert.equal(retGreet, greeting, "Provided and Requested greeting differs");
});
});
});