-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-5-ownership.js
72 lines (62 loc) · 1.82 KB
/
test-5-ownership.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import BigNumber from 'bignumber.js'
import {
assert,
assertRevert,
getAddresses,
ether,
assertTxSucceedsGeneratingEvents,
} from './helpers'
const TestToken = artifacts.require('./TestToken.sol')
const WavestreamPresale = artifacts.require('./WavestreamPresale.sol')
contract(`WavestreamPresale (ownership):`, accounts => {
const addr = getAddresses(accounts)
const rate = 100 // 100 tokens for 1 Ether, assuming token.digits is 18
let presale
let token
before(async () => {
token = await TestToken.new(ether(5000), {from: addr.owner})
presale = await WavestreamPresale.new(
rate,
addr.priorityWallet,
ether(7),
addr.wallet,
ether(50),
token.address,
{from: addr.owner},
)
await token.transfer(presale.address, ether(5000), {from: addr.owner})
})
it(`sets owner properly`, async () => {
const owner = await presale.owner()
assert.equal(addr.owner, owner)
})
it(`non-owner address cannot transfer ownership to a non-owner`, async () => {
await assertRevert(
presale.transferOwnership(addr.anonymous, {
from: addr.anonymous,
}),
)
})
it(`owner can't transfer ownership to 0x0 address`, async () => {
await assertRevert(presale.transferOwnership('0x0', {from: addr.owner}))
})
it(`owner can transfer ownership, generating event`, async () => {
const expectedEvent = {
name: 'OwnershipTransferred',
args: {
previousOwner: addr.owner,
newOwner: addr.anonymous,
},
}
await assertTxSucceedsGeneratingEvents(
await presale.transferOwnership(addr.anonymous, {
from: addr.owner,
}),
[expectedEvent],
)
})
it(`new owner is set properly`, async () => {
const newOwner = await presale.owner()
assert.equal(addr.anonymous, newOwner)
})
})