1

I have a crowdsale contract that inherits RefundableCrowdsale.sol from OpenZeppelin. I was using their v1.10.0 initially, but now revamping it using v1.12.0.

contract TestTokenCrowdsale is Crowdsale, MintedCrowdsale, CappedCrowdsale, TimedCrowdsale, WhitelistedCrowdsale, RefundableCrowdsale { ... }

and wrote a test script to test refunds.

In v1.10.0 this worked:

const RefundVault = artifacts.require('./RefundVault');

contract('TestTokenCrowdsale', function(accounts) {
    beforeEach(async function () {
        ...
        this.goal = ether(50);

        this.crowdsale = await TestTokenCrowdsale.new(
            ...
            this.goal
        );

        // Track refund vault
        this.vaultAddress = await this.crowdsale.vault();
        this.vault = RefundVault.at(this.vaultAddress);
    )};

    describe('during crowdsale', function() {
      it('prevents other accounts from claiming refund', async function() {
        await this.vault.refund(accounts[2], { from: accounts[2]}).should.be.rejectedWith(EVMRevert);
      });
    });    
}

But in v1.12.0 RefundVault.sol has changed to RefundEscrow.sol.

Before, I could track refund vault in beforeEach.

this.vaultAddress = await this.crowdsale.vault();
this.vault = RefundVault.at(this.vaultAddress); 

This was possible because this.crowdsale.vault() is public in v1.10.0. However, since in v1.12.0 escrow became private, I'm not sure how to modify it accordingly.

this.vault.refund won't work either because they removed refund in v1.12.0 as well.

How can I change to test prevents other accounts from claiming refund in v1.12.0?

2

Suggest you look at the OpenZeppelin v1.12 test for RefundableCrowdsale for how to test that refunds are denied. RefundableCrowdsale.test.js

  it('should deny refunds before end', async function () {
    await expectThrow(this.crowdsale.claimRefund({ from: investor }), EVMRevert);
    await increaseTimeTo(this.openingTime);
    await expectThrow(this.crowdsale.claimRefund({ from: investor }), EVMRevert);
  });

  it('should deny refunds after end if goal was reached', async function () {
    await increaseTimeTo(this.openingTime);
    await this.crowdsale.sendTransaction({ value: goal, from: investor });
    await increaseTimeTo(this.afterClosingTime);
    await expectThrow(this.crowdsale.claimRefund({ from: investor }), EVMRevert);
  });

You may want to look at moving to OpenZeppelin 2.2

Also OpenZeppelin 2.3 RC3

If you have more questions about OpenZeppelin you can always ask in the forum

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.