-
Notifications
You must be signed in to change notification settings - Fork 2
/
FTM_test_2.rb
134 lines (90 loc) · 3.49 KB
/
FTM_test_2.rb
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
require_relative "FTM_ini"
File.basename(__FILE__) =~ /(\d+)\.rb$/
@sot.test_nr = $1
###############################################################################
jump_to(50, 'epoch 50')
@sl.h1 'Minting'
###
@sot.txt 'Mint unrestricted tokens'
@sot.own :mint_tokens, 1, @a[1], 50_000_000 * @E18
@sot.own :mint_tokens, 1, @a[11], 50_000_000 * @E18
accts, tokens = [], []
(2..6).each do |i|
accts << @a[i]
tokens << 10_000_000 * @E18
end
@sot.own :mint_tokens_multiple, 5, accts, tokens
@sot.exp :balance_of, @a[1], 50_000_000 * @E18, 50_000_000 * @E18
@sot.exp :balances_minted_by_type, [@a[1], 1], 50_000_000 * @E18, 50_000_000 * @E18
@sot.exp :balances_minted_by_type, [@a[1], 5], 0, 0
(2..6).each do |i|
@sot.exp :balance_of, @a[i], 10_000_000 * @E18, 10_000_000 * @E18
@sot.exp :balances_minted_by_type, [@a[i], 5], 10_000_000 * @E18, 10_000_000 * @E18
end
@sot.exp :balance_of, @a[11], 0, 0
@sot.exp :available_to_mint, 300_000_000 * @E18, -100_000_000 * @E18
@sot.do
###
@sot.txt 'Mint locked tokens - fail because we only have 5 slots'
accts = Array.new(6, @a[10])
tokens = Array.new(6, 10_000_000 * @E18)
terms = [200, 300, 400, 500, 600, 700]
@sot.own :mint_tokens_locked_multiple, 1, accts, tokens, terms
@sot.exp :balance_of, @a[10], 0, 0
@sot.do
###
@sot.txt 'Mint locked tokens'
@sot.own :mint_tokens_locked, 2, @a[10], 10_000_000 * @E18, 100
accts = Array.new(4, @a[10])
tokens = Array.new(4, 10_000_000 * @E18)
terms = [200, 300, 400, 500]
@sot.own :mint_tokens_locked_multiple, 3, accts, tokens, terms
@sot.exp :balance_of, @a[10], 50_000_000 * @E18, 50_000_000 * @E18
@sot.exp :locked_tokens, @a[10], 50_000_000 * @E18, 50_000_000 * @E18
@sot.exp :unlocked_tokens, @a[10], 0
@sot.exp :is_available_lock_slot, [@a[10], 500], true
@sot.exp :is_available_lock_slot, [@a[10], 600], false
@sot.exp :is_available_lock_slot, [@a[10], 700], false
@sot.exp :available_to_mint, 250_000_000 * @E18, -50_000_000 * @E18
@sot.do
###
jump_to(100, 'epoch 100')
@sot.txt 'Still no lock slot'
@sot.exp :is_available_lock_slot, [@a[10], 900], false
@sot.do
###
jump_to(101, 'epoch 101') # modifies locked tokens
@sot.txt 'Now we should have a lock slot'
@sot.exp :is_available_lock_slot, [@a[10], 600], true
@sot.exp :locked_tokens, @a[10], 40_000_000 * @E18, 0
@sot.do
###
@sot.txt 'Now we should have a single lock slot'
@sot.own :mint_tokens_locked, 2, @a[10], 20_000_000 * @E18, 800
@sot.own :mint_tokens_locked, 2, @a[10], 20_000_000 * @E18, 900
@sot.exp :balance_of, @a[10], 70_000_000 * @E18, 20_000_000 * @E18
@sot.exp :locked_tokens, @a[10], 60_000_000 * @E18, 20_000_000 * @E18
@sot.exp :unlocked_tokens, @a[10], nil, 0
@sot.exp :is_available_lock_slot, [@a[10], 900], false
@sot.exp :available_to_mint, 230_000_000 * @E18, -20_000_000 * @E18
@sot.do
###
jump_to(200, 'epoch 200')
@sot.txt 'Still no lock slot'
@sot.exp :unlocked_tokens, @a[10], nil, 0
@sot.exp :is_available_lock_slot, [@a[10], 900], false
@sot.do
jump_to(201, 'epoch 201') # again modifies unlocked
@sot.txt 'Now there is another lock slot'
@sot.exp :unlocked_tokens, @a[10], 20_000_000 * @E18, 0
@sot.exp :is_available_lock_slot, [@a[10], 900], true
@sot.exp :may_have_locked_tokens, @a[10], true
@sot.do
jump_to(901, 'epoch 901')
@sot.txt 'Now we should have nothing locked...'
@sot.exp :unlocked_tokens, @a[10], 70_000_000 * @E18, nil
@sot.exp :may_have_locked_tokens, @a[10], true
@sot.do
###############################################################################
@sot.dump
output_pp @sot.get_state(true), "state_#{@sot.test_nr}.txt"