对比特币的一个小小的、非炫耀性的模仿

bitcoind-mock的Python项目详细描述


比特币模拟

tippin.me

bitcoindmock是一种为单元测试模拟bitcoind的方法。它对于Continuous integration (CI)工具特别有用。在

mock提供了一个JSON-RPC接口,其中包含bitcoind中可用的一些RPC命令以及zmq 事务和块通知接口。mock还提供了额外的端点来生成块 请求(/generate)并创建分叉(/fork)。在

模拟可以由time运行,其中块将以固定的时间间隔生成,也可以由events运行,其中一个块 将在每次调用/generate时生成。在

以下是当前部分覆盖的命令:

decoderawtransaction:   querying for the decoding of a raw transaction will return a dictionary with a single
                        field: "txid".

sendrawtransaction:     sending a rawtransaction will notify our mining simulator to include such transaction in
                        a subsequent block (add it to mempool).

getrawtransaction:      requesting a rawtransaction from a txid will return a dictionary containing a single
                        field: "confirmations", since rawtransactions are only queried to check whether a
                        transaction has made it to a block or not.

getblockcount:          the block count represents the length of the longest chain.

getblock:               querying for a block will return a dictionary with three fields: "tx" representing a
                        list of transactions, "height" representing the block height and "hash" representing the
                        block hash.

getblockhash:           returns the hash of a block given its height.

getbestblockhash:       returns the hash of the block in the tip of the chain.

help:                   help is only used as a sample command to test if bitcoind is running when bootstrapping.
                        It will return a 200/OK with no data.

已知限制

  • 实现的命令不会返回bitcoind将返回的每个字段,只返回最重要的字段(或 在我自己的单元测试中需要的)。在

  • 当与via python交互时,mock可以很好地工作,但是如果由bitcoin-cli直接查询(检查#1),则不能正常工作。在

  • zmq只通知正在挖掘的块,但不通知事务。在

  • 运行mock bytime时请求fork将不会重置将在其上挖掘的块的计时器 叉形的那个。在

依赖性

请参阅DEPENCENCIES.md。在

安装

您可以从PyPi获取包:

pip install bitcoind-mock

或手动安装(请参阅INSTALL.md)。在

贡献

如果您想添加/扩展任何命令,请随时发送一份PR。我们可以通过加入来完成此任务 努力:微笑:

请参阅CONTRIBUTING.md以了解要遵循的样式准则。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有类注册的java工厂方法模式生成nullpointer异常   java PSI和索引不匹配:在Android Studio上PSI和索引不匹配   JavaSpring使用一个应用程序。用于生产的属性和用于调试的属性   java在哪里被卡住了?   JMF中的java更大分辨率   java我如何在HashMap中只找到某些实体的最高值,而不是整个HashMap?   Android中偏好和共享偏好的java差异   swing Java:ScrollablePicture使其在给定坐标下滚动   java如何转换GMT?   使用PolicyFactory后,xss HtmlPolicyBuilder样式不会出现在<tr>和<table>标记中。java代码中的清理   java如何在pgAdmin3中显示使用Hibernate插入的文本值?   java我需要从视图类中的主要活动中获取上下文   java如何确保字符串没有数字   java合并特定逻辑的整数数组列表   eclipse java数据库与OOP的连接   java如何获得Div中的子元素的计数甚至文本列表