This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflow issuance+acquisition+redemption
- Loading branch information
Showing
6 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pragma solidity ^0.4.12; | ||
|
||
contract CouponRegistry { | ||
uint storedData; | ||
|
||
function set(uint x) { | ||
storedData = x; | ||
} | ||
|
||
function get() constant returns (uint) { | ||
return storedData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var CouponExample = artifacts.require("./CouponExample.sol"); | ||
|
||
contract('CouponExample', function(accounts) { | ||
|
||
var user1 = accounts[2]; | ||
const initialBalance_user1 = web3.eth.getBalance(user1) | ||
console.log(web3.fromWei(initialBalance_user1).toString()) | ||
|
||
it("give a coupon to a user", function() { | ||
var coupon; | ||
var issuer; | ||
|
||
return CouponExample.deployed().then(function(instance) { | ||
coupon = instance; | ||
return coupon.creator.call(); | ||
}).then(function(address) { | ||
creator = address | ||
return coupon.issue({from: creator}); | ||
}).then(function() { | ||
return coupon.hasCoupon.call(user1); | ||
}).then(function(result) { | ||
assert.equal(result, false, "User1 already acquire this coupon"); | ||
return coupon.giveCoupon(user1,{from: creator}); | ||
}).then(function() { | ||
return coupon.hasCoupon.call(user1); | ||
}).then(function(result) { | ||
assert.equal(result, true, "User1 acquisition didnt work"); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var CouponExample = artifacts.require("./CouponExample.sol"); | ||
|
||
contract('CouponExample', function(accounts) { | ||
|
||
it("should have 100 free coupons at creation", function() { | ||
return CouponExample.deployed().then(function(instance) { | ||
return instance.totalFreeCoupon.call(); | ||
}).then(function(total) { | ||
assert.equal(total.valueOf(), 100, "Total free Coupon(s) should be 100 initially"); | ||
}); | ||
}); | ||
|
||
it("should change state after issuance", function() { | ||
var coupon; | ||
|
||
return CouponExample.deployed().then(function(instance) { | ||
coupon = instance; | ||
return coupon.creator.call(); | ||
}).then(function(creator) { | ||
return coupon.issue({from: creator}); | ||
}).then(function() { | ||
return coupon.state.call(); | ||
}).then(function(state) { | ||
assert.equal(state, 1, "State has not changed after issuance"); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters