فهرست منبع

Remove payable from Destructible constructor (#1107)

* Destructible no longer has a payable constructor.

* Fixed linter errors.
Nicolás Venturo 7 سال پیش
والد
کامیت
73be06412f
3فایلهای تغییر یافته به همراه15 افزوده شده و 5 حذف شده
  1. 0 3
      contracts/lifecycle/Destructible.sol
  2. 7 0
      contracts/mocks/DestructibleMock.sol
  3. 8 2
      test/lifecycle/Destructible.test.js

+ 0 - 3
contracts/lifecycle/Destructible.sol

@@ -9,9 +9,6 @@ import "../ownership/Ownable.sol";
  * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
  */
 contract Destructible is Ownable {
-
-  constructor() public payable { }
-
   /**
    * @dev Transfers the current balance to the owner and terminates the contract.
    */

+ 7 - 0
contracts/mocks/DestructibleMock.sol

@@ -0,0 +1,7 @@
+pragma solidity ^0.4.24;
+
+import "../lifecycle/Destructible.sol";
+
+contract DestructibleMock is Destructible {
+  function() payable public {}
+}

+ 8 - 2
test/lifecycle/Destructible.test.js

@@ -1,9 +1,15 @@
-var Destructible = artifacts.require('Destructible');
+const DestructibleMock = artifacts.require('DestructibleMock');
 const { ethGetBalance } = require('../helpers/web3');
 
 contract('Destructible', function (accounts) {
   beforeEach(async function () {
-    this.destructible = await Destructible.new({ from: accounts[0], value: web3.toWei('10', 'ether') });
+    this.destructible = await DestructibleMock.new({ from: accounts[0] });
+    await web3.eth.sendTransaction({
+      from: accounts[0],
+      to: this.destructible.address,
+      value: web3.toWei('10', 'ether'),
+    });
+
     this.owner = await this.destructible.owner();
   });