Truffle-Migration

部署腳本警告,可能是錯誤

  • August 17, 2018
var CredentialOrgFactory = artifacts.require("CredentialOrgFactory");
var CredentialFactory = artifacts.require("CredentialFactory");
var ApplicantFactory = artifacts.require("ApplicantFactory");
//var ProcessCredentials = artifacts.require("ProcessCredentials");

module.exports = async(deployer) => {
   let deployCredentialOrgFactory = await deployer.deploy(CredentialOrgFactory);
   let deployCredentialFactory = await deployer.deploy(CredentialFactory);
   contractCredentialFactory = await CredentialFactory.deployed()
   let setAddress = await contractTwo.setAddress(
       CredentialOrgFactory.address,
       { gas: 200000 }
   );
};

留言:

(node:13120) UnhandledPromiseRejectionWarning: E​​rror: VM Exception while processing transaction: revert

//一些不重要的東西 //

(node:13120) UnhandledPromiseRejectionWarning: 未處理的承諾拒絕。此錯誤源於在沒有 catch 塊的情況下拋出非同步函式內部,或拒絕未使用 .catch() 處理的承諾。(拒絕 ID:1)

(節點:13120)

$$ DEP0018 $$DeprecationWarning:不推薦使用未處理的承諾拒絕。將來,未處理的 Promise 拒絕將使用非零退出程式碼終止 Node.js 程序。 2_deploy_contracts.js 文件中的正確編碼是什麼?也許我沒有正確設置 CredentialFactory 的地址?想法?我有點卡在自動取款機上。

它可能是測試文件的一部分。

pragma 穩固性 ^0.4.21;

import "truffle/Assert.sol";  
import "truffle/DeployedAddresses.sol";  
import "../contracts/CredentialFactory.sol";  

contract TestCredentialFactory {  
CredentialFactory credentialFactory = CredentialFactory(DeployedAddresses.CredentialFactory());  


   function testIsActiveValid() public {  
       bool r = credentialFactory.isCredentialActive(0x2259aA88Cc0aa3d83d5ec5aF6096C627778FBD06, 0);  
       Assert.isTrue(r, "Valid isActive Test.");  
   }  

   function testIsActiveInvalid() public {  
       bool r = credentialFactory.isCredentialActive(0x5a186B7FeC36909678211F69beB67EC3b1E4fFBB, 5);  
       Assert.isFalse(r, "Outside Range IsActive Test");  
   }  
   function SelectOrgCredentialCount() public {  
       uint256 testVal = uint256(credentialFactory.SelectOrgCredentialCount(0x2259aA88Cc0aa3d83d5ec5aF6096C627778FBD06));  
       uint256 expected = 1;  
       Assert.equal(testVal, expected, "Expected Credential Count (1)");  
   }  

}  

這種佈局清除了事情並允許等待發生。

var CredentialOrgFactory = artifacts.require("CredentialOrgFactory");  
var CredentialFactory = artifacts.require("CredentialFactory");  
var ApplicantFactory = artifacts.require("ApplicantFactory");  
//var ProcessApplicants = artifacts.require("ProcessApplicants");  

module.exports = async function(deployer, accounts) {  
   let aInst, bInst, cInst, dInst;
   let aAccount;

await Promise.all([
 deployer.deploy(CredentialOrgFactory),
 deployer.deploy(CredentialFactory),
 deployer.deploy(ApplicantFactory)
 // deployer.deploy(ProcessApplicants)
]);

instances = await Promise.all([
 CredentialOrgFactory.deployed(),
 CredentialFactory.deployed(),
 ApplicantFactory.deployed()
 //ProcessApplicants.deployed()
])

aInst = instances[0];
bInst = instances[1];
cInst = instances[2];
//dInst = instances[3];

results = await Promise.all([
 bInst.setAddress(aInst.address),
 cInst.setAddress(aInst.address),
 //dInst.setAddress(aInst.address, bInst.address, cInst.address)
]);

};

不是您的具體問題的答案,但它可以解決它:

目前我正在使用這個庫:https ://github.com/LimeChain/etherlime 來部署它與 async/await 一起使用的合約,並且在每次部署結束時都有一個很好的報告。目前它甚至支持像松露一樣的測試。在底層使用 ethersjs 比使用 web3js 更穩定和可預測。

引用自:https://ethereum.stackexchange.com/questions/56219