Spectrum鏈開發準備篇-Windows環境下調通測試代碼,執行單元測試

來源:互聯網
上載者:User

系統內容 win10

註:不同windows發布版本安裝過程可能略有不同

環境依賴:

Go, GCC

Go下載地址: https://golang.org/dl/

筆者下載的是1.10.2.   64位版本:

完整下載地址: https://dl.google.com/go/go1.10.2.windows-amd64.msi

安裝:

筆者安裝的路徑為 C:\Go目錄下. 添加   C:\Go\bin到環境變數中.

任意目錄下執行go version,顯示版本號碼則安裝配置成功.

C:\Users\tangshua>go version

go version go1.10.2 windows/amd64

MinGw下載地址 : https://sourceforge.net/projects/mingw-w64/

筆者下載的GW完整下載地址: https://jaist.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe

安裝MinGW:

筆者安裝在D:\mingw-w64,安裝完成後如下. 添加D:\mingw-w64\bin到環境變數中.

Spectrum安裝

下載源檔案

https://github.com/SmartMeshFoundation/Spectrum

筆者放在了D盤.切換到tests目錄.  執行Go test -v


其它點:

執行報錯解決辦法:

1.   將代碼放在Go目錄下.

C:\Go\src\github.com\SmartMeshFoundation\Spectrum

筆者在block_test_util.go代碼中發現如下定義,可能導致相應類庫無法找到而報錯.

import ( "bytes" "encoding/hex" "encoding/json" "fmt" "math/big" "github.com/SmartMeshFoundation/Spectrum/common" "github.com/SmartMeshFoundation/Spectrum/common/hexutil" "github.com/SmartMeshFoundation/Spectrum/common/math" "github.com/SmartMeshFoundation/Spectrum/consensus/ethash" "github.com/SmartMeshFoundation/Spectrum/core" "github.com/SmartMeshFoundation/Spectrum/core/state" "github.com/SmartMeshFoundation/Spectrum/core/types" "github.com/SmartMeshFoundation/Spectrum/core/vm" "github.com/SmartMeshFoundation/Spectrum/ethdb" "github.com/SmartMeshFoundation/Spectrum/params" "github.com/SmartMeshFoundation/Spectrum/rlp")

2.   在tests目錄下建立testdata目錄,同時在testdata目錄下分別建立

BlockchainTests,GeneralStateTests,TransactionTests,VMTests,RLPTests,BasicTests目錄。

筆者在init_test.go 檔案中發現如下定義:

var ( baseDir = filepath.Join(".", "testdata") blockTestDir = filepath.Join(baseDir, "BlockchainTests") stateTestDir = filepath.Join(baseDir, "GeneralStateTests") transactionTestDir = filepath.Join(baseDir, "TransactionTests") vmTestDir = filepath.Join(baseDir, "VMTests") rlpTestDir = filepath.Join(baseDir, "RLPTests") difficultyTestDir = filepath.Join(baseDir, "BasicTests"))

但是並未在檔案夾中發現,因此手動建立了改檔案夾.




相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.