@gooddollar/goodprotocol 1.0.13-beta.0 → 1.0.13-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "1.0.13-beta.0",
3
+ "version": "1.0.13-beta.1",
4
4
  "description": "GoodDollar Protocol",
5
5
  "scripts": {
6
6
  "build": "scripts/build.sh deploy",
@@ -218,6 +218,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
218
218
  expect(totalStakedBeforeStake).to.be.equal(0);
219
219
  expect(totalStakedAfterStake).to.be.gt(totalStakedBeforeStake);
220
220
  });
221
+
221
222
  it("it should stake donations with DAI", async () => {
222
223
  let stakeAmount = ethers.utils.parseEther("10");
223
224
  await dai["mint(address,uint256)"](donationsStaking.address, stakeAmount);
@@ -228,6 +229,13 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
228
229
  stakeAmount
229
230
  );
230
231
  });
232
+
233
+ it("it should reverted when there is no token to stake", async () => {
234
+ await expect(donationsStaking.stakeDonations()).to.be.revertedWith(
235
+ "no stakingToken to stake"
236
+ );
237
+ });
238
+
231
239
  it("it should stake donations with ETH according to 0.3% of pool", async () => {
232
240
  let stakeAmount = ethers.utils.parseEther("20");
233
241
  const pairContract = await ethers.getContractAt(
@@ -263,6 +271,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
263
271
  expect(stakeAmount).to.be.gt(maxAmount);
264
272
  expect(stakeAmount.sub(maxAmount)).to.be.equal(ethBalanceAfterStake); // check leftover ETH in contract
265
273
  });
274
+
266
275
  it("withdraw should reverted if caller not avatar", async () => {
267
276
  const tx = await donationsStaking
268
277
  .connect(staker)
@@ -270,6 +279,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
270
279
  .catch(e => e);
271
280
  expect(tx.message).to.have.string("only avatar can call this method");
272
281
  });
282
+
273
283
  it("it should withdraw donationStaking when caller is avatar and return funds to avatar", async () => {
274
284
  const totalStakedBeforeEnd = await donationsStaking.totalStaked();
275
285
  const avatarDaiBalanceBeforeEnd = await dai.balanceOf(avatar);
@@ -305,16 +315,9 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
305
315
 
306
316
  expect(totalStakedAfterEnd).to.be.equal(0);
307
317
  });
318
+
308
319
  it("it should set stakingContract when avatar call it ", async () => {
309
320
  let stakeAmount = ethers.utils.parseEther("6000"); // Max swap amount is around 5964 with current liquidity level so we should set it to higher number in order to test functionality
310
- const donationsStakingFactory = await ethers.getContractFactory(
311
- "DonationsStaking",
312
- {
313
- libraries: {
314
- UniswapV2SwapHelper: swapHelper.address
315
- }
316
- }
317
- );
318
321
 
319
322
  await dai["mint(address,uint256)"](donationsStaking.address, stakeAmount);
320
323
  await donationsStaking.stakeDonations();
@@ -342,7 +345,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
342
345
  .then(async contract => {
343
346
  await contract.init(
344
347
  bat.address,
345
- cDAI.address,
348
+ cBat.address,
346
349
  nameService.address,
347
350
  "Good BAT",
348
351
  "gBAT",
@@ -353,12 +356,7 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
353
356
  );
354
357
  return contract;
355
358
  });
356
- //let encodedData = donationsStakingFactory.interface.encodeFunctionData(
357
- // "setStakingContract",
358
- // [simpleStaking.address, [NULL_ADDRESS, bat.address]]
359
- //);
360
- //
361
- //await genericCall(donationsStaking.address, encodedData);
359
+
362
360
  await donationsStaking.setStakingContract(simpleStaking.address, [
363
361
  NULL_ADDRESS,
364
362
  bat.address
@@ -390,4 +388,9 @@ describe("DonationsStaking - DonationStaking contract that receives funds in ETH
390
388
  ); // It should send leftover stakingToken to avatar after swap to ETH in safeAmount
391
389
  expect(stakingAmountBeforeSet).to.be.gt(safeAmount); // maxSafeAmount must be smaller than actualstaking amount so we can verify that we hit the limit for transaction amount at once
392
390
  });
391
+
392
+ it("it should return version of DonationsStaking properly", async () => {
393
+ const version = await donationsStaking.getVersion();
394
+ expect(version).to.be.equal("2.0.0");
395
+ });
393
396
  });