Skip to content

feat(bundles repair): add bundle repair worker PE-4041 #566

feat(bundles repair): add bundle repair worker PE-4041

feat(bundles repair): add bundle repair worker PE-4041 #566

GitHub Actions / Mocha tests succeeded Jun 29, 2023 in 0s

Mocha tests ✅

Tests passed successfully

✅ test-results.json

93 tests were completed in 16s with 93 passed, 0 failed and 0 skipped.

Test suite Passed Failed Skipped Time
src/data/read-through-chunk-data-cache.test.ts 3✅ 17ms
src/data/tx-chunks-data-source.test.ts 4✅ 8ms
src/database/standalone-sqlite.test.ts 23✅ 7s
src/filters.test.ts 21✅ 30ms
src/lib/encoding.test.ts 15✅ 129ms
src/routes/graphql/resolvers.test.ts 9✅ 39ms
src/workers/block-importer.test.ts 18✅ 461ms

✅ src/data/read-through-chunk-data-cache.test.ts

ReadThroughChunkDataCache getChunkDataByAny
  ✅ should fetch chunk data from cache when available
  ✅ should fetch chunk data from network when an error occurs fetching from local cache
  ✅ should fetch chunk data from network when not in local cache

✅ src/data/tx-chunks-data-source.test.ts

TxChunksDataSource getContiguousData a bad piece of chunk data
  ✅ should throw an error
TxChunksDataSource getContiguousData a bad piece of chunk data an invalid chunk
  ✅ should throw an error
TxChunksDataSource getContiguousData a valid transaction id
  ✅ should return chunk data of the correct size for a known chunk
TxChunksDataSource getContiguousData an invalid transaction id
  ✅ should throw an error

✅ src/database/standalone-sqlite.test.ts

SQLite data conversion functions dataItemToDbRows
  ✅ should return DB rows to insert
SQLite GraphQL cursor functions decodeBlockGqlCursor
  ✅ should decode a height given an encoded cursor
  ✅ should return an undefined height given an undefined cursor
  ✅ should throw an error given an invalid cursor
SQLite GraphQL cursor functions decodeTransactionGqlCursor
  ✅ should decode a height and blockTransactionIndex given an encoded cursor
  ✅ should return an undefined height, blockTransactionIndex, and dataItemId given an undefined cursor
  ✅ should throw an error given an invalid cursor
SQLite GraphQL cursor functions encodeBlockGqlCursor
  ✅ should encode a cursor given a height
SQLite GraphQL cursor functions encodeTransactionGqlCursor
  ✅ should encode a cursor given a height and blockTransactionIndex
SQLite helper functions toSqliteParams
  ✅ should convert SQL Bricks param values to better-sqlite3 params
StandaloneSqliteDatabase saveBlockAndTxs
  ✅ should copy all the block fields to the stable_blocks table
  ✅ should copy all the owner fields to the stable_transactions table
  ✅ should copy all the transaction fields to the stable_transactions table
  ✅ should flush blocks and transactions to stable tables
  ✅ should insert the block in the new_blocks table
  ✅ should save missing transaction IDs in missing_transactions
  ✅ should save stable transaction IDs to stable_block_transactions
  ✅ should save the block transactions in the new_transactions table
StandaloneSqliteDatabase saveTx
  ✅ should insert into new_transaction_tags
  ✅ should insert into new_transactions
  ✅ should insert into tag_names
  ✅ should insert into tag_values
  ✅ should insert into wallets

✅ src/filters.test.ts

AlwaysMatch
  ✅ should always return true
createFilter
  ✅ should return AlwaysMatch for filter with always
  ✅ should return MatchAll for filter with and
  ✅ should return MatchAny for filter with or
  ✅ should return MatchAttributes for filter with tags
  ✅ should return MatchTags for filter with tags
  ✅ should return NeverMatch for filter with never
  ✅ should return NeverMatch for undefined or empty filter
  ✅ should throw an error for invalid filter
MatchAll
  ✅ should return false if any filter does not match
  ✅ should return true if all filters match
MatchAny
  ✅ should return false if none of the filters match
  ✅ should return true if any filters match
MatchAttributes
  ✅ should match all attributes
  ✅ should not match if any attribute is different
  ✅ should not match if any attribute is missing
MatchTags
  ✅ should match all tags
  ✅ should not match if some tag value prefixes are incorrect
  ✅ should not match if some tag values are incorrect
  ✅ should not match if some tags are missing
NeverMatch
  ✅ should always return false

✅ src/lib/encoding.test.ts

Base64 URL encoding functions b64UrlToUtf8
  ✅ should convert a Base64 URL encoded string to UTF8
Base64 URL encoding functions fromB64Url
  ✅ should convert a Base64 URL encoded string to a Buffer
Base64 URL encoding functions sha256B64Url
  ✅ should convert a Buffer to a Base64 URL encoded SHA256 string
Base64 URL encoding functions toB64Url
  ✅ should convert a Buffer to a Base64 URL encoded string
  ✅ should convert a Buffer with padding to Base64 URL encoded string
Base64 URL encoding functions utf8ToB64Url
  ✅ should convet a UTF8 string to a Base64 URL encoded string
Block message pack encoding and decoding functions jsonBlockToMsgpack and msgpackToJsonBlock
  ✅ should round trip to and from MessagePack binary data
Block message pack encoding and decoding functions jsonBlockToMsgpackBlock and msgpackBlockToJsonBlock
  ✅ should round trip to and from a MsgpackBlock
Manifest parsing resolveManifestStreamPath
  ✅ should return the ID for non-index paths
  ✅ should return the ID for the index path
  ✅ should return undefined if the path is not found
Message pack encoding and decoding functions toMsgpack and fromMsgpack
  ✅ should preserve compatibility with 'standard' MessagePack
  ✅ should round trip to and from MessagePack binary data
Transaction message pack encoding and decoding functions jsonTxToMsgpack and msgpackToJsonTx
  ✅ should round trip to and from MessagePack binary data
Transaction message pack encoding and decoding functions jsonTxToMsgpackTx and msgpackTxToJsonTx
  ✅ should round trip to and from a MsgpackTransaction

✅ src/routes/graphql/resolvers.test.ts

getPageSize
  ✅ should return 'first' if it is set and less than MAX_PAGE_SIZE
  ✅ should return DEFAULT_PAGE_SIZE if 'first' is not set
  ✅ should return MAX_PAGE_SIZE if 'first' is greater than MAX_PAGE_SIZE
resolveTxData
  ✅ should return dataSize and contentType
resolveTxFee
  ✅ should return quantity in AR and winstons
resolveTxOwner
  ✅ should return owner address and key
resolveTxQuantity
  ✅ should return quantity in AR and winstons
resolveTxRecipient
  ✅ should return empty string if recipient is undefined
  ✅ should return the recipient

✅ src/workers/block-importer.test.ts

BlockImporter getNextHeight when blocks have been imported but the chain is not fully synced
  ✅ should return one more than the max height in the DB
BlockImporter getNextHeight when no blocks have been imported
  ✅ should return the start height
BlockImporter getNextHeight when the chain is fully synced
  ✅ should return one more than the max height in the DB if multiple blocks are produced while waiting
  ✅ should wait for the next block to be produced
BlockImporter importBlock attempting to import a block after a fork
  ✅ should reimport the block where the fork occured
  ✅ should reset the height to where the fork occured
BlockImporter importBlock attempting to import a block following a gap that exceeds the max fork depth
  ✅ should throw an exception
BlockImporter importBlock attempting to import a block with a gap before it
  ✅ should import only 1 block
  ✅ should import the first block at the start of the gap
BlockImporter importBlock importing a block
  ✅ should add the block to the DB
  ✅ should add the block's transactions to the DB
  ✅ should increase the max height
BlockImporter importBlock importing a block with missing transactions
  ✅ should add the block to the DB
  ✅ should add the block's transactions to the DB
  ✅ should add the IDs of the missing transactions to DB
  ✅ should increase the max height
BlockImporter start
  ✅ should not throw an exception when called (smoke test)
BlockImporter stop
  ✅ should not throw an exception when called (smoke test)