Spectrum链开发准备篇-Windows环境下调通测试代码,执行单元测试

lunhuimeng · · 605 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

系统环境 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") )

但是并未在文件夹中发现,因此手动创建了改文件夹.





有疑问加站长微信联系(非本文作者)

本文来自:简书

感谢作者:lunhuimeng

查看原文:Spectrum链开发准备篇-Windows环境下调通测试代码,执行单元测试

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

605 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传