@@ -17,7 +17,8 @@ const ACL = artifacts.require("ACL");
17
17
18
18
const Web3 = require ( '../src/web3' ) ;
19
19
const {
20
- buyArtistTokens,
20
+ buyArtistTokenWrapper,
21
+ withdrawArtistTokens
21
22
} = require ( '../src/contracts/profile' ) ;
22
23
23
24
const {
@@ -98,19 +99,35 @@ contract('Profile', (accounts) => {
98
99
} ) ;
99
100
100
101
console . log ( `Buying ${ amountInPht } artist tokens` ) ;
101
- const bougthAmount = await buyArtistTokens ( web3 , {
102
+ const bougthAmount = await buyArtistTokenWrapper ( web3 , {
102
103
from : FAN_ACCOUNT ,
103
104
contractAddr : fanProfileInstance . address ,
104
105
artistTokenAddr : artistTokenInstance . address ,
105
106
wphtAddr : wphtInstance . address ,
106
107
amountInPht
107
108
} ) ;
108
109
109
- const balanceOf = await getBalanceOf ( web3 , {
110
+ const balanceOfContract = await getBalanceOf ( web3 , {
110
111
artistTokenAddr : artistTokenInstance . address ,
111
112
accountAddr : fanProfileInstance . address
112
113
} ) ;
113
114
114
- assert . equal ( bougthAmount , balanceOf ) ;
115
+ assert . equal ( bougthAmount , balanceOfContract ) ;
116
+
117
+ // Withdraw artist tokens back to user
118
+ await withdrawArtistTokens ( web3 , {
119
+ from : FAN_ACCOUNT ,
120
+ beneficiary : FAN_ACCOUNT ,
121
+ contractAddr : fanProfileInstance . address ,
122
+ amount : balanceOfContract ,
123
+ artistToken : artistTokenInstance . address
124
+ } ) ;
125
+
126
+ const balanceOfUser = await getBalanceOf ( web3 , {
127
+ artistTokenAddr : artistTokenInstance . address ,
128
+ accountAddr : FAN_ACCOUNT
129
+ } ) ;
130
+
131
+ assert . equal ( bougthAmount , balanceOfUser ) ;
115
132
} ) ;
116
133
} ) ;
0 commit comments