Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing test coverage #70

Closed
43 tasks done
buck54321 opened this issue Feb 6, 2020 · 19 comments
Closed
43 tasks done

Missing test coverage #70

buck54321 opened this issue Feb 6, 2020 · 19 comments

Comments

@buck54321
Copy link
Member

buck54321 commented Feb 6, 2020

Follows up on #34 and #35. Also related to #38.

Here is a list of areas needing unit test coverage for decred.

decred/config.py ................ moved to tinywallet
decred/crypto/secp256k1/curve.py  80% -> 99%
decred/dcr/account.py ............64% -> 98%
decred/dcr/calc.py .............. removed
decred/dcr/dcrdata.py ........... 65% -> 97%
decred/dcr/rpc.py ............... 95%
decred/dcr/txscript.py .......... 82% -> 94%
decred/dcr/vsp.py ............... 43% -> 94%
decred/util/encode.py ........... 96% -> 100%
decred/util/helpers.py .......... 100%
decred/util/tinyhttp.py ......... 100%
decred/wallet/api.py ............ removed
decred/wallet/wallet.py ......... 95%

Selected notes

Some specific areas lacking coverage. I've added some recommendations for tests to translate from dcrd where possible.

curve.py

account.py

  • TicketRequest constructor
  • TicketInfo.parse
  • UTXO class, numerous methods
  • Account class, numerous methods (mostly done. maybe a couple more paths worth hitting)

dcrdata.py

  • DcrdataPath class
  • AgendaChoices class
  • AgendasInfo class
  • makeOutputs function
  • checkOutput function

The following will benefit greatly from having a fake network connection class. @teknico has previously pointed to the pytest monkeypatching fixture, but I haven't looked too closely yet.

txscript.py

  • finalOpcodeData function

  • isStakeScriptHash function

  • checkSStx function negative paths

  • asSmallInt function

  • payToAddrScript unsupported sig type exceptions

  • multiSigScript function

  • payToSSRtxSHDirect function

  • payToSStxChange script-hash paths

  • int2octets and bits2octets functions

  • nonceRFC6979 function. Consider simplifying this function if we aren't going to use the extra and version arguments. Needs additional investigation.

  • verifySig function: TestPrivKeys

  • putVarInt function: TestPutVarInt

  • addInt function: TestScriptBuilderAddInt64

  • addData function: TestScriptBuilderAddData

  • signP2PKHMsgTx function negative paths

  • paysHighFees function

  • extractPkScriptAddrs function

  • mergeScripts function. May find some additional subtests in TestSignTxOutput

  • getP2PKHOpCode function

  • spendScriptSize function

  • calcMinRequiredTxRelayFee function: TestCalcMinRequiredTxRelayFee

  • isUnspendable function: TestIsUnspendable

  • isDustOutput function

  • Other negative paths sparsely throughout that could get some coverage.

vsp.py

  • Another module that will benefit from a fake connection.

encode.py

  • blobStrList function
  • unblobStrList function
  • spurious negative paths

helpers.py

The following unused code has been removed, the remaining is entirely tested.

  • moveFile function
  • yearmonthday function
  • recursiveUpdate function
  • Benchmarker class
  • formatNumber function
  • saveFile, fetchSettingsFile, saveJSON, and loadJSON functions
  • appDataDir function: TestAppDataDir. will require significant adaptation.

api.py

Considering dropping this module altogether. It's really just API definitions, but it's drifing out-of-date
and will require a massive rewrite when multi-asset is implemented.

EDIT: removed, together with calc.py.

wallet.py

All of it. Might need to create a test Blockchain class.

@JoeGruffins
Copy link
Member

I'd like to do the vsp tests, unless @teknico is already working on it?

@teknico
Copy link
Collaborator

teknico commented Feb 9, 2020

@JoeGruffins I'm not, go ahead.

@teknico
Copy link
Collaborator

teknico commented Feb 10, 2020

I'll take curve.py if no one is working on it.

@teknico
Copy link
Collaborator

teknico commented Feb 17, 2020

I'll do the dcrdata ones next, including the fake network connection class.

@buck54321
Copy link
Member Author

Don't worry too much about the WebSocketClient in dcrdata. I'm moving that and rewriting some parts.

@JoeGruffins
Copy link
Member

I will start on txscript tests if that's ok. From the bottom, one at a time, will do isDustAmount first.

@teknico
Copy link
Collaborator

teknico commented Mar 19, 2020

Not sure where that 96% for dcr/rpc.py came from, by the way: it's actually 32% which actually means totally untested.

@buck54321
Copy link
Member Author

It's 96% with integration tests. At least it is for me.

@teknico
Copy link
Collaborator

teknico commented Mar 19, 2020

Uhm, weird. The coverage-html.sh script does include all tests, not just the unit ones. What command are you running?

@buck54321
Copy link
Member Author

I'm using coverage-html.sh. RPC tests are run against a local node by parsing your dcrd configuration file to get parameters. I would imagine the tests would fail if you're not running dcrd or don't have a configuration file in the expected spot, but I haven't tested that assumption.

@teknico
Copy link
Collaborator

teknico commented Mar 19, 2020

Ah, the skipped tests! Makes sense, I'll try executing coverage-html.sh with dcrd running. Thanks.

@buck54321
Copy link
Member Author

Oh yeah. I forgot there was a pytest.skip there when the config fixture is None.

@teknico
Copy link
Collaborator

teknico commented Mar 19, 2020

I had to run dcrd with both the --txindex and --addrindex options (and wait accordingly for the indexes to be computed) for the RPC tests to run. Then I got an error and I had to make this change to have tests pass:

 cFilterHeader414000 = ByteArray(
-    "412f12ed5bd92df6a8b17cf396697cd44d84ada67f5ca3b1c3f23f3b7619984b"
+    "a854742e7b3b8cd4f48fd2568c021e24bde9aaf07f1898cf0a9c1f133bcfe115"
 )

@buck54321
Copy link
Member Author

What dcrd version are you running?

@teknico
Copy link
Collaborator

teknico commented Mar 20, 2020

The decrediton one:
dcrd version 1.5.1+release (Go version go1.13.7 linux/amd64)

EDIT: solved after dropping and rebuilding the CF index in my local dcrd.

@teknico
Copy link
Collaborator

teknico commented Mar 24, 2020

After applying #136 and #137, overall test coverage is up to 95%. 🎉

20 files have 100% coverage, 9 above 90% and only 3 below. Getting close. 🙂

@teknico
Copy link
Collaborator

teknico commented Mar 25, 2020

After applying #138 and #142, the overall test coverage is up to 97%.

All files have at least 90%. 🙂

The most remaining work is on dcr/txscript.py, being dealt with by @JoeGruffins.

This was referenced Mar 27, 2020
@teknico
Copy link
Collaborator

teknico commented Mar 31, 2020

Total coverage 98%, all files have at least 94%. Looking at dcr/rpc.py.

@buck54321
Copy link
Member Author

Nice work, @teknico and @JoeGruffins. Closing now.

decred is in a great state, so I'll plan on tagging a release now.

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

No branches or pull requests

3 participants