Spectrum Chain Development Prepare-Debug Test Code And Execute Unit Test On Windows Environment

Kenny
Kenny
Sep 8, 2018 · 2 min read

System Environment: win10

Note: Different versions may differ

Devopment Dependencies:

Go, GCC

Go download address: https://golang.org/dl/

Author download 1.10.2. 64 bit version:

full download address: https://dl.google.com/go/go1.10.2.windows-amd64.msi

install:

I installed directory C:\Go . added C:\Go\bin to system environment.

execute go version, if show the go version number, install successfully.

C:\Users\tangshua>go version

go version go1.10.2 windows/amd64

MinGw download : https://sourceforge.net/projects/mingw-w64/

full download address:

https://jaist.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe

install MinGW:

I installed at D:\mingw-w64, after installation. added D:\mingw-w64\bin to system environment.

Spectrum installation

download sourcecode:

https://github.com/SmartMeshFoundation/Spectrum

go to the tests folder. execute Go test -v

Other point:

solved errors:

1. put the code at go folder.

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

I found that below code definition at block_test_util.go, maybe case error as some library can’t be found.

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. create testdata folder in tests folder. and create below folders in testdata.

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

I found below code at 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”))

but no relation folders found in the source code downloaded from github.

SmartMesh Developer Community

Welcome to contribute, have the opportunity to get SMT rewards, and be invited to join smartmesh developer community.

Kenny

Written by

Kenny

SmartMesh Developer Community

Welcome to contribute, have the opportunity to get SMT rewards, and be invited to join smartmesh developer community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade