Skip to content

FakeBitcoinProxy: a mock RPC implementation.#136

Merged
petertodd merged 1 commit into
petertodd:masterfrom
kanzure:fakebitcoinproxy
Jan 2, 2019
Merged

FakeBitcoinProxy: a mock RPC implementation.#136
petertodd merged 1 commit into
petertodd:masterfrom
kanzure:fakebitcoinproxy

Conversation

@kanzure

@kanzure kanzure commented Mar 9, 2017

Copy link
Copy Markdown
Collaborator

FakeBitcoinProxy provides an interface similar to the bitcoin.rpc.Proxy API. Downstream applications interested in unit testing can use FakeBitcoinProxy as an alternative to elaborate Proxy mocks. This interface returns similar values as Proxy and is intended to have similar behavior.

Unit tests are provided and they are passing.

We've been using FakeBitcoinProxy since 2015 to test many different bitcoin applications, which have also been tested against bitcoin nodes running on regtest, testnet and mainnet. Specifically, we pass in FakeBitcoinProxy instead of a bitcoin connection and we get back the same behavior in these different environments using the same interface.

Ideally, this contribution would also include tests to show parity between Proxy and FakeBitcoinProxy, even against active bitcoind nodes, but given extensive usage in multiple environments it seems like less of a priority right now.

An interesting future direction for this would be to load test blockchain data from bitcoind regtest files, and then load that up for testing. I have some tools for handcrafting regtest reorg scenarios using FakeBitcoinProxy but I think it would be better to load from file and do less handcrafting.

Use FakeBitcoinProxy as an alternative to mocking bitcoin.rpc.Proxy in
unit tests by downstream applications. FakeBitcoinProxy implements a
similar interface and returns values similar to those from the
bitcoin.rpc.Proxy API.

Downstream applications could use this for unit testing their bitcoin
applications, leaving bitcoind "regtest" for integration testing modes
instead.

Also, unit tests for FakeBitcoinProxy are provided.
@petertodd

Copy link
Copy Markdown
Owner

Mind adding the standard copyright headers that are in other files in this repo to the new files?

@dgpv

dgpv commented Dec 10, 2018

Copy link
Copy Markdown
Contributor

@kanzure we want to merge this code into https://github.com/Simplexum/python-bitcointx, but as the files do not have standard copyright headers, it is unclear if this code is OK to add to LGPLv3 library and be covered under this license. It may be implied by the fact that this is a pull request to LGPLv3 lib, but still, this is not explicit.

Could you please clarify the license status of this code ?

@petertodd

Copy link
Copy Markdown
Owner

License is the same as the rest of the code; I got permission from the owner (LedgerX) to clarify things.

@petertodd petertodd merged commit 4b5c0b6 into petertodd:master Jan 2, 2019
petertodd added a commit that referenced this pull request Jan 2, 2019
4b5c0b6 FakeBitcoinProxy: a mock RPC implementation. (Bryan Bishop)

Pull request description:

  FakeBitcoinProxy provides an interface similar to the bitcoin.rpc.Proxy API. Downstream applications interested in unit testing can use FakeBitcoinProxy as an alternative to elaborate Proxy mocks. This interface returns similar values as Proxy and is intended to have similar behavior.

  Unit tests are provided and they are passing.

  We've been using FakeBitcoinProxy since 2015 to test many different bitcoin applications, which have also been tested against bitcoin nodes running on regtest, testnet and mainnet. Specifically, we pass in FakeBitcoinProxy instead of a bitcoin connection and we get back the same behavior in these different environments using the same interface.

  Ideally, this contribution would also include tests to show parity between Proxy and FakeBitcoinProxy, even against active bitcoind nodes, but given extensive usage in multiple environments it seems like less of a priority right now.

  An interesting future direction for this would be to load test blockchain data from bitcoind regtest files, and then load that up for testing. I have some tools for handcrafting regtest reorg scenarios using FakeBitcoinProxy but I think it would be better to load from file and do less handcrafting.

Tree-SHA512: 3d358abb4278903c068619da2b370a06b93438638974c4fa57a658dc76342d44e68ff1f85dc2065de39968ce6a2689e2eb38fef7616e82eba2451ec86f47793b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants