@@ -17,7 +17,8 @@ const ACL = artifacts.require("ACL");
1717
1818const Web3 = require ( '../src/web3' ) ;
1919const {
20- buyArtistTokens,
20+ buyArtistTokenWrapper,
21+ withdrawArtistTokens
2122} = require ( '../src/contracts/profile' ) ;
2223
2324const {
@@ -98,19 +99,35 @@ contract('Profile', (accounts) => {
9899 } ) ;
99100
100101 console . log ( `Buying ${ amountInPht } artist tokens` ) ;
101- const bougthAmount = await buyArtistTokens ( web3 , {
102+ const bougthAmount = await buyArtistTokenWrapper ( web3 , {
102103 from : FAN_ACCOUNT ,
103104 contractAddr : fanProfileInstance . address ,
104105 artistTokenAddr : artistTokenInstance . address ,
105106 wphtAddr : wphtInstance . address ,
106107 amountInPht
107108 } ) ;
108109
109- const balanceOf = await getBalanceOf ( web3 , {
110+ const balanceOfContract = await getBalanceOf ( web3 , {
110111 artistTokenAddr : artistTokenInstance . address ,
111112 accountAddr : fanProfileInstance . address
112113 } ) ;
113114
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 ) ;
115132 } ) ;
116133} ) ;
0 commit comments