@@ -672,4 +672,33 @@ contract('JoinAndQuit', accounts => {
672
672
assert . equal ( ( await testSetup . standardTokenMock . balanceOf ( accounts [ 3 ] ) ) . toString ( ) , donatorBalance . toString ( ) ) ;
673
673
} ) ;
674
674
675
+ it ( "refund with eth" , async function ( ) {
676
+ var testSetup = await setup ( accounts , true ) ;
677
+ var tx = await testSetup . joinAndQuit . proposeToJoin (
678
+ "description-hash" ,
679
+ testSetup . minFeeToJoin ,
680
+ { from :accounts [ 3 ] , value :testSetup . minFeeToJoin } ) ;
681
+
682
+ //Vote with reputation to trigger execution
683
+ var proposalId = await helpers . getValueFromLogs ( tx , '_proposalId' , 1 ) ;
684
+ await testSetup . joinAndQuitParams . votingMachine . absoluteVote . vote ( proposalId , 1 , 0 , helpers . NULL_ADDRESS , { from :accounts [ 2 ] } ) ;
685
+ assert . equal ( ( await testSetup . joinAndQuit . fundings ( accounts [ 3 ] ) ) . funding , testSetup . minFeeToJoin ) ;
686
+ try {
687
+ await testSetup . joinAndQuit . refund ( { from :accounts [ 3 ] } ) ;
688
+ assert ( false , 'cannot refund before deadline' ) ;
689
+ } catch ( ex ) {
690
+ helpers . assertVMException ( ex ) ;
691
+ }
692
+ await helpers . increaseTime ( testSetup . fundingGoalDeadline ) ;
693
+ var balanceBefore = await avatarBalance ( testSetup ) ;
694
+ tx = await testSetup . joinAndQuit . refund ( { from :accounts [ 3 ] } ) ;
695
+ assert . equal ( tx . logs . length , 1 ) ;
696
+ assert . equal ( tx . logs [ 0 ] . event , "Refund" ) ;
697
+ assert . equal ( tx . logs [ 0 ] . args . _avatar , testSetup . org . avatar . address ) ;
698
+ assert . equal ( tx . logs [ 0 ] . args . _beneficiary , accounts [ 3 ] ) ;
699
+ assert . equal ( tx . logs [ 0 ] . args . _refund , testSetup . minFeeToJoin ) ;
700
+ assert . equal ( await avatarBalance ( testSetup ) , balanceBefore - testSetup . minFeeToJoin ) ;
701
+ } ) ;
702
+
703
+
675
704
} ) ;
0 commit comments