@@ -1045,3 +1045,66 @@ test('request rebalance - send same targetAllocation', async t => {
1045
1045
rebalanceCount : 1 ,
1046
1046
} ) ;
1047
1047
} ) ;
1048
+
1049
+ test ( 'creatorFacet.withdrawFees' , async t => {
1050
+ const { started, common } = await setupTrader ( t ) ;
1051
+ const { storage } = common . bootstrap ;
1052
+ const { inspectLocalBridge } = common . utils ;
1053
+
1054
+ const { contractAccount } = storage
1055
+ . getDeserialized ( `${ ROOT_STORAGE_PATH } ` )
1056
+ . at ( - 1 ) as unknown as { contractAccount : string } ;
1057
+ t . log ( 'contractAddress for fees' , contractAccount ) ;
1058
+
1059
+ const { bld } = common . brands ;
1060
+ const bld2k = bld . units ( 2_000 ) ;
1061
+ {
1062
+ const pmt = await common . utils . pourPayment ( bld2k ) ;
1063
+ const { bankManager } = common . bootstrap ;
1064
+ const bank = E ( bankManager ) . getBankForAddress ( contractAccount ) ;
1065
+ const purse = E ( bank ) . getPurse ( bld2k . brand ) ;
1066
+ await E ( purse ) . deposit ( pmt ) ;
1067
+ t . log ( 'deposited' , bld2k , 'for fees' ) ;
1068
+ }
1069
+
1070
+ const { creatorFacet } = started ;
1071
+
1072
+ const dest = `cosmos:agoric-3:${ makeTestAddress ( 5 ) } ` as const ;
1073
+
1074
+ {
1075
+ const actual = await E ( creatorFacet ) . withdrawFees ( dest , {
1076
+ denom : 'ubld' ,
1077
+ value : 100n ,
1078
+ } ) ;
1079
+ t . log ( 'withdrew some' , actual ) ;
1080
+
1081
+ t . deepEqual ( actual , { denom : 'ubld' , value : 100n } ) ;
1082
+
1083
+ const [ tx ] = inspectLocalBridge ( ) . filter (
1084
+ obj => obj . type === 'VLOCALCHAIN_EXECUTE_TX' ,
1085
+ ) ;
1086
+ t . like ( tx . messages [ 0 ] , {
1087
+ '@type' : '/cosmos.bank.v1beta1.MsgSend' ,
1088
+ fromAddress : 'agoric1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqp7zqht' ,
1089
+ toAddress : 'agoric1q5qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq8ee25y' ,
1090
+ amount : [ { denom : 'ubld' , amount : '100' } ] ,
1091
+ } ) ;
1092
+ }
1093
+
1094
+ {
1095
+ const amt = await E ( creatorFacet ) . withdrawFees ( dest ) ;
1096
+
1097
+ t . log ( 'withdrew all' , amt ) ;
1098
+ t . deepEqual ( amt , { denom : 'ubld' , value : bld2k . value } ) ;
1099
+
1100
+ const [ _ , tx ] = inspectLocalBridge ( ) . filter (
1101
+ obj => obj . type === 'VLOCALCHAIN_EXECUTE_TX' ,
1102
+ ) ;
1103
+ t . like ( tx . messages [ 0 ] , {
1104
+ '@type' : '/cosmos.bank.v1beta1.MsgSend' ,
1105
+ fromAddress : 'agoric1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqp7zqht' ,
1106
+ toAddress : 'agoric1q5qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq8ee25y' ,
1107
+ amount : [ { denom : 'ubld' , amount : '2000000000' } ] ,
1108
+ } ) ;
1109
+ }
1110
+ } ) ;
0 commit comments