operate-bsv / op_agent-js

Operate JavaScript agent used to load and run Bitcoin programs.
https://www.operatebsv.org
MIT License
4 stars 3 forks source link

Implement Bob.fetchTxBy() #3

Closed libitx closed 4 years ago

libitx commented 4 years ago

Elixir reference code: https://github.com/operate-bsv/op_agent/blob/master/lib/operate/adapter/bob.ex#L71-L86

Elixir test code: https://github.com/operate-bsv/op_agent/blob/master/test/operate/adapter/bob_test.exs#L23-L51

Implement both the above function and test in JavaScript. The test should pass without a mock first, and then the exact mock from the Elixir repo can be copied over.

MerlinB commented 4 years ago

I think there is a small inconsistency in your Elixir test: Setting a limit of 3 will return 3 elements in c and another 3 in u if available. Your current test should fail without the mock without filtering out unconfirmed txns. Anyway, I merged the commit.

libitx commented 4 years ago

I see what you mean. I don't want to filter out the unconfirmed tx, so I guess this this just needs to be one of those quirks of bitdb - setting a limit of n may give you anything up to n * 2. 🤷‍♂ I suppose the correct test would check a length between 3 and 6.

Thanks for the commit.