2017-09-26 14 views
1

geth, truffle 및 testrpc가 제대로 설치되었습니다. 이제 Ethereum 계약 자습서를 작성하려고합니다. 프로젝트를 truffle init으로 초기화 했으므로 기본 계약이있는 프로젝트 폴더가 생성 된 후 testrpc을 실행하고 truffle compile을 입력하여 계약을 컴파일했습니다 (빌드 디렉토리가 성공적으로 생성되었습니다). 문제는, truffle test은 실행중인 testrpc가없는 것처럼 작동하지 않습니다. Windows에서 Git Bash를 사용하고 있습니다. 무엇이 문제일까요? ScreenEthereum 클라이언트 (testrpc)에 연결할 수 없습니다.

답변

0

확인이 밖으로 당신이 truffle test

  • 를 실행하기 전에 당신은 두 개의 CMD 창을 필요 디렉토리에 테스트 파일이 필요

    1. ,
      • 하나 testrpc 명령을 (안 실행 종료),
      • 두 번째 컴파일 할 창
        컴파일하려면 b 명령을 실행하십시오. Web3 = require('web3') web3 = new Web3(new Web3.providers.HttpProvider(" http://localhost:8545 ") solc = require('solc') sourceCode = fs.readFileSync('ContractFile.sol').toString() compileCode = solc.compile(sourceCode) //Get the interface of contract contractABI = JSON.parse(compileCode.contracts[':ContractFile'].interface) //Get the bytecode of the contract bytecode = compiledCode.contracts[':ContractFile'].bytecode //Ready to deploy ContractFileContract = web3.eth.contract(contractABI) //use the object above to deploy the contract ContractDeployed = ContractFileContract.new({data: bytecode, from: web3.eth.account[0], gas: 4700000}) //Check your testrpc console.
    2. 는 계약의 상단에 견고 버전을 declear하는 것을 잊지 마세요 elow.