refactor: use sdk functions instead of fake mocks for tests#210
Conversation
| sinon.stub(EcdsaMPCv2Utils.prototype, 'getBitgoMpcv2PublicGpgKey').resolves(pgpKey); | ||
| const bitgoEd25519Key = await openpgpUtils.generateGPGKeyPair('ed25519'); | ||
|
|
||
| nock(bitgoApiUrl) |
There was a problem hiding this comment.
would this pr introduce any latency for ci test as we now using sdk functions?
There was a problem hiding this comment.
Don't think so, when running tests locally any latency was not noticeable, and looking at CI shows that the testing job for this PR took 1m 9 seconds, exactly the same time as in this older PR https://github.com/BitGo/advanced-wallets/actions/runs/25590599173/job/75127489578
pranishnepal
left a comment
There was a problem hiding this comment.
will review further after current feedback is addressed!
| import { BitGoAPI } from '@bitgo-beta/sdk-api'; | ||
| import { readKey } from 'openpgp'; | ||
|
|
||
| class BitGoAPITestHarness extends BitGoAPI { |
There was a problem hiding this comment.
Move this to a shared util file, then use it in tests
There was a problem hiding this comment.
made a testUtils.ts
| txInfo: { nP2SHInputs: 1, nSegwitInputs: 0, nOutputs: 2 }, | ||
| walletId, | ||
| }); | ||
| const prebuildStub = sinon |
There was a problem hiding this comment.
Should we add a nock for this also?
There was a problem hiding this comment.
was able to nock all prebuild tx stubs in sendMany
| }, | ||
| walletId, | ||
| }); | ||
| const prebuildStub = sinon |
There was a problem hiding this comment.
same question about prebuilds
An initial pass of updating the tests to use the actual SDK functions instead of mocked SDK behavior.
ecdsa.test.ts,eddsa.test.ts,generateWallet.test.ts,sendMany.test.tsBitGoAPITestHarness, my idea was to keep adding static methods to this class as needed as I de- mock more test files. Right now I haveclearConstantsCache()so when any tests nock/api/v1/client/constants, we can get clean client constants data for each test. Should I create a utils file to move this to so we can import it instead?Ticket: WAL-1489