@@ -2,12 +2,11 @@ const UFragments = artifacts.require('UFragments.sol');
22const _require = require ( 'app-root-path' ) . require ;
33const BlockchainCaller = _require ( '/util/blockchain_caller' ) ;
44const chain = new BlockchainCaller ( web3 ) ;
5- const { ContractEventSpy } = _require ( '/util/spies' ) ;
65
76const truffleConfig = _require ( '/truffle.js' ) ;
87const accounts = truffleConfig . accounts ;
98
10- let uFragments , b , eventSpy ;
9+ let uFragments , b , r ;
1110
1211async function setContractReferences ( ) {
1312 uFragments = await UFragments . new ( ) ;
@@ -54,19 +53,14 @@ contract('UFragments:PauseRebase', function () {
5453 before ( 'setup UFragments contract' , async function ( ) {
5554 await setContractReferences ( ) ;
5655 await uFragments . setMonetaryPolicy ( policy , { from : deployer } ) ;
57- eventSpy = new ContractEventSpy ( [ uFragments . RebasePaused ] ) ;
58- eventSpy . watch ( ) ;
59- await uFragments . setRebasePaused ( true ) ;
60- } ) ;
61-
62- after ( async function ( ) {
63- eventSpy . stopWatching ( ) ;
56+ r = await uFragments . setRebasePaused ( true ) ;
6457 } ) ;
6558
6659 it ( 'should emit pause event' , async function ( ) {
67- const pauseEvent = eventSpy . getEventByName ( 'RebasePaused' ) ;
68- expect ( pauseEvent ) . to . exist ;
69- expect ( pauseEvent . args . paused ) ;
60+ const log = r . logs [ 0 ] ;
61+ expect ( log ) . to . exist ;
62+ expect ( log . event ) . to . eq ( 'RebasePaused' ) ;
63+ expect ( log . args . paused ) . to . be . true ;
7064 } ) ;
7165
7266 it ( 'should not allow calling rebase' , async function ( ) {
@@ -117,19 +111,14 @@ contract('UFragments:PauseToken', function () {
117111 before ( 'setup UFragments contract' , async function ( ) {
118112 await setContractReferences ( ) ;
119113 await uFragments . setMonetaryPolicy ( policy , { from : deployer } ) ;
120- eventSpy = new ContractEventSpy ( [ uFragments . TokenPaused ] ) ;
121- eventSpy . watch ( ) ;
122- await uFragments . setTokenPaused ( true ) ;
123- } ) ;
124-
125- after ( async function ( ) {
126- eventSpy . stopWatching ( ) ;
114+ r = await uFragments . setTokenPaused ( true ) ;
127115 } ) ;
128116
129117 it ( 'should emit pause event' , async function ( ) {
130- const pauseEvent = eventSpy . getEventByName ( 'TokenPaused' ) ;
131- expect ( pauseEvent ) . to . exist ;
132- expect ( pauseEvent . args . paused ) ;
118+ const log = r . logs [ 0 ] ;
119+ expect ( log ) . to . exist ;
120+ expect ( log . event ) . to . eq ( 'TokenPaused' ) ;
121+ expect ( log . args . paused ) . to . be . true ;
133122 } ) ;
134123
135124 it ( 'should allow calling rebase' , async function ( ) {
@@ -212,13 +201,7 @@ contract('UFragments:Rebase:Expansion', function () {
212201 await setContractReferences ( ) ;
213202 await uFragments . setMonetaryPolicy ( policy , { from : deployer } ) ;
214203 await uFragments . transfer ( A , 250 , { from : deployer } ) ;
215- eventSpy = new ContractEventSpy ( [ uFragments . Rebase ] ) ;
216- eventSpy . watch ( ) ;
217- await uFragments . rebase ( 1 , 500 , { from : policy } ) ;
218- } ) ;
219-
220- after ( async function ( ) {
221- eventSpy . stopWatching ( ) ;
204+ r = await uFragments . rebase ( 1 , 500 , { from : policy } ) ;
222205 } ) ;
223206
224207 it ( 'should increase the totalSupply' , async function ( ) {
@@ -235,10 +218,11 @@ contract('UFragments:Rebase:Expansion', function () {
235218 } ) ;
236219
237220 it ( 'should emit Rebase' , async function ( ) {
238- const rebaseEvent = eventSpy . getEventByName ( 'Rebase' ) ;
239- expect ( rebaseEvent ) . to . exist ;
240- expect ( rebaseEvent . args . epoch . toNumber ( ) ) . to . eq ( 1 ) ;
241- expect ( rebaseEvent . args . totalSupply . toNumber ( ) ) . to . eq ( 1500 ) ;
221+ const log = r . logs [ 0 ] ;
222+ expect ( log ) . to . exist ;
223+ expect ( log . event ) . to . eq ( 'Rebase' ) ;
224+ expect ( log . args . epoch . toNumber ( ) ) . to . eq ( 1 ) ;
225+ expect ( log . args . totalSupply . toNumber ( ) ) . to . eq ( 1500 ) ;
242226 } ) ;
243227} ) ;
244228
@@ -252,13 +236,7 @@ contract('UFragments:Rebase:Contraction', function () {
252236 await setContractReferences ( ) ;
253237 await uFragments . setMonetaryPolicy ( policy , { from : deployer } ) ;
254238 await uFragments . transfer ( A , 250 , { from : deployer } ) ;
255- eventSpy = new ContractEventSpy ( [ uFragments . Rebase ] ) ;
256- eventSpy . watch ( ) ;
257- await uFragments . rebase ( 1 , - 500 , { from : policy } ) ;
258- } ) ;
259-
260- after ( async function ( ) {
261- eventSpy . stopWatching ( ) ;
239+ r = await uFragments . rebase ( 1 , - 500 , { from : policy } ) ;
262240 } ) ;
263241
264242 it ( 'should decrease the totalSupply' , async function ( ) {
@@ -275,10 +253,11 @@ contract('UFragments:Rebase:Contraction', function () {
275253 } ) ;
276254
277255 it ( 'should emit Rebase' , async function ( ) {
278- const rebaseEvent = eventSpy . getEventByName ( 'Rebase' ) ;
279- expect ( rebaseEvent ) . to . exist ;
280- expect ( rebaseEvent . args . epoch . toNumber ( ) ) . to . eq ( 1 ) ;
281- expect ( rebaseEvent . args . totalSupply . toNumber ( ) ) . to . eq ( 500 ) ;
256+ const log = r . logs [ 0 ] ;
257+ expect ( log ) . to . exist ;
258+ expect ( log . event ) . to . eq ( 'Rebase' ) ;
259+ expect ( log . args . epoch . toNumber ( ) ) . to . eq ( 1 ) ;
260+ expect ( log . args . totalSupply . toNumber ( ) ) . to . eq ( 500 ) ;
282261 } ) ;
283262} ) ;
284263
0 commit comments