@bsv/sdk 1.3.12 → 1.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +15 -3
- package/dist/cjs/src/auth/Peer.js +83 -57
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/SessionManager.js +14 -9
- package/dist/cjs/src/auth/SessionManager.js.map +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js +16 -10
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +25 -23
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +2 -2
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +62 -46
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +1 -0
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +70 -43
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/auth/utils/createNonce.js +2 -1
- package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
- package/dist/cjs/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/validateCertificates.js +5 -2
- package/dist/cjs/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js +2 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/cjs/src/compat/BSM.js +7 -17
- package/dist/cjs/src/compat/BSM.js.map +1 -1
- package/dist/cjs/src/compat/ECIES.js +172 -133
- package/dist/cjs/src/compat/ECIES.js.map +1 -1
- package/dist/cjs/src/compat/HD.js +63 -73
- package/dist/cjs/src/compat/HD.js.map +1 -1
- package/dist/cjs/src/compat/Mnemonic.js +102 -106
- package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
- package/dist/cjs/src/compat/Utxo.js +2 -2
- package/dist/cjs/src/compat/Utxo.js.map +1 -1
- package/dist/cjs/src/compat/index.js +7 -17
- package/dist/cjs/src/compat/index.js.map +1 -1
- package/dist/cjs/src/messages/EncryptedMessage.js +3 -1
- package/dist/cjs/src/messages/EncryptedMessage.js.map +1 -1
- package/dist/cjs/src/messages/SignedMessage.js +1 -0
- package/dist/cjs/src/messages/SignedMessage.js.map +1 -1
- package/dist/cjs/src/messages/index.js +7 -17
- package/dist/cjs/src/messages/index.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +54 -35
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js +32 -20
- package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +40 -28
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/cjs/src/primitives/AESGCM.js +6 -5
- package/dist/cjs/src/primitives/AESGCM.js.map +1 -1
- package/dist/cjs/src/primitives/BasePoint.js +1 -1
- package/dist/cjs/src/primitives/BasePoint.js.map +1 -1
- package/dist/cjs/src/primitives/BigNumber.js +50 -62
- package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
- package/dist/cjs/src/primitives/Curve.js +46 -22
- package/dist/cjs/src/primitives/Curve.js.map +1 -1
- package/dist/cjs/src/primitives/DRBG.js +2 -8
- package/dist/cjs/src/primitives/DRBG.js.map +1 -1
- package/dist/cjs/src/primitives/ECDSA.js +51 -35
- package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
- package/dist/cjs/src/primitives/Hash.js +191 -216
- package/dist/cjs/src/primitives/Hash.js.map +1 -1
- package/dist/cjs/src/primitives/JacobianPoint.js +19 -5
- package/dist/cjs/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/cjs/src/primitives/K256.js.map +1 -1
- package/dist/cjs/src/primitives/Mersenne.js.map +1 -1
- package/dist/cjs/src/primitives/MontgomoryMethod.js.map +1 -1
- package/dist/cjs/src/primitives/Point.js +117 -88
- package/dist/cjs/src/primitives/Point.js.map +1 -1
- package/dist/cjs/src/primitives/Polynomial.js +4 -2
- package/dist/cjs/src/primitives/Polynomial.js.map +1 -1
- package/dist/cjs/src/primitives/PrivateKey.js +32 -33
- package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
- package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
- package/dist/cjs/src/primitives/Random.js +6 -5
- package/dist/cjs/src/primitives/Random.js.map +1 -1
- package/dist/cjs/src/primitives/ReductionContext.js +1 -1
- package/dist/cjs/src/primitives/ReductionContext.js.map +1 -1
- package/dist/cjs/src/primitives/Schnorr.js +21 -15
- package/dist/cjs/src/primitives/Schnorr.js.map +1 -1
- package/dist/cjs/src/primitives/Signature.js +8 -7
- package/dist/cjs/src/primitives/Signature.js.map +1 -1
- package/dist/cjs/src/primitives/SymmetricKey.js +13 -13
- package/dist/cjs/src/primitives/SymmetricKey.js.map +1 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +31 -29
- package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/cjs/src/primitives/index.js +7 -17
- package/dist/cjs/src/primitives/index.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js +79 -68
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/script/OP.js +3 -3
- package/dist/cjs/src/script/OP.js.map +1 -1
- package/dist/cjs/src/script/Script.js +12 -10
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +47 -49
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/script/templates/P2PKH.js +24 -12
- package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js +28 -23
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/src/script/templates/RPuzzle.js +10 -6
- package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +2 -1
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +177 -154
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefParty.js +24 -24
- package/dist/cjs/src/transaction/BeefParty.js.map +1 -1
- package/dist/cjs/src/transaction/BeefTx.js +26 -18
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
- package/dist/cjs/src/transaction/Broadcaster.js +3 -2
- package/dist/cjs/src/transaction/Broadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +64 -37
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +111 -137
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/ARC.js +25 -16
- package/dist/cjs/src/transaction/broadcasters/ARC.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +2 -1
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js +2 -1
- package/dist/cjs/src/transaction/chaintrackers/DefaultChainTracker.js.map +1 -1
- package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
- package/dist/cjs/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js +5 -3
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/FetchHttpClient.js +5 -2
- package/dist/cjs/src/transaction/http/FetchHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/NodejsHttpClient.js +5 -3
- package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/index.js.map +1 -1
- package/dist/cjs/src/transaction/index.js.map +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js +91 -66
- package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/KeyDeriver.js +61 -52
- package/dist/cjs/src/wallet/KeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/ProtoWallet.js +79 -29
- package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js +7 -2
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/WalletError.js +2 -2
- package/dist/cjs/src/wallet/WalletError.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +4 -3
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +2 -2
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1239 -1261
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +102 -43
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +8 -3
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/window.CWI.js +28 -28
- package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +15 -15
- package/dist/esm/src/auth/Peer.js +75 -54
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/SessionManager.js +14 -9
- package/dist/esm/src/auth/SessionManager.js.map +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js +15 -11
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +25 -23
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +2 -2
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +64 -47
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +1 -0
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +69 -43
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
- package/dist/esm/src/auth/utils/getVerifiableCertificates.js +1 -1
- package/dist/esm/src/auth/utils/getVerifiableCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/validateCertificates.js +6 -3
- package/dist/esm/src/auth/utils/validateCertificates.js.map +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/esm/src/compat/BSM.js.map +1 -1
- package/dist/esm/src/compat/ECIES.js +165 -116
- package/dist/esm/src/compat/ECIES.js.map +1 -1
- package/dist/esm/src/compat/HD.js +56 -56
- package/dist/esm/src/compat/HD.js.map +1 -1
- package/dist/esm/src/compat/Mnemonic.js +95 -89
- package/dist/esm/src/compat/Mnemonic.js.map +1 -1
- package/dist/esm/src/compat/Utxo.js +1 -1
- package/dist/esm/src/compat/Utxo.js.map +1 -1
- package/dist/esm/src/messages/EncryptedMessage.js +3 -1
- package/dist/esm/src/messages/EncryptedMessage.js.map +1 -1
- package/dist/esm/src/messages/SignedMessage.js +1 -0
- package/dist/esm/src/messages/SignedMessage.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +53 -35
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js +32 -20
- package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -1
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +40 -28
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/esm/src/primitives/AESGCM.js +1 -0
- package/dist/esm/src/primitives/AESGCM.js.map +1 -1
- package/dist/esm/src/primitives/BasePoint.js +1 -1
- package/dist/esm/src/primitives/BasePoint.js.map +1 -1
- package/dist/esm/src/primitives/BigNumber.js +50 -62
- package/dist/esm/src/primitives/BigNumber.js.map +1 -1
- package/dist/esm/src/primitives/Curve.js +45 -22
- package/dist/esm/src/primitives/Curve.js.map +1 -1
- package/dist/esm/src/primitives/DRBG.js +2 -8
- package/dist/esm/src/primitives/DRBG.js.map +1 -1
- package/dist/esm/src/primitives/ECDSA.js +50 -35
- package/dist/esm/src/primitives/ECDSA.js.map +1 -1
- package/dist/esm/src/primitives/Hash.js +188 -213
- package/dist/esm/src/primitives/Hash.js.map +1 -1
- package/dist/esm/src/primitives/JacobianPoint.js +18 -5
- package/dist/esm/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/esm/src/primitives/K256.js.map +1 -1
- package/dist/esm/src/primitives/Mersenne.js.map +1 -1
- package/dist/esm/src/primitives/MontgomoryMethod.js.map +1 -1
- package/dist/esm/src/primitives/Point.js +107 -88
- package/dist/esm/src/primitives/Point.js.map +1 -1
- package/dist/esm/src/primitives/Polynomial.js +4 -2
- package/dist/esm/src/primitives/Polynomial.js.map +1 -1
- package/dist/esm/src/primitives/PrivateKey.js +25 -16
- package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
- package/dist/esm/src/primitives/PublicKey.js.map +1 -1
- package/dist/esm/src/primitives/Random.js +7 -6
- package/dist/esm/src/primitives/Random.js.map +1 -1
- package/dist/esm/src/primitives/ReductionContext.js +1 -1
- package/dist/esm/src/primitives/ReductionContext.js.map +1 -1
- package/dist/esm/src/primitives/Schnorr.js +21 -15
- package/dist/esm/src/primitives/Schnorr.js.map +1 -1
- package/dist/esm/src/primitives/Signature.js +8 -7
- package/dist/esm/src/primitives/Signature.js.map +1 -1
- package/dist/esm/src/primitives/SymmetricKey.js +13 -13
- package/dist/esm/src/primitives/SymmetricKey.js.map +1 -1
- package/dist/esm/src/primitives/TransactionSignature.js +22 -12
- package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/esm/src/primitives/utils.js +76 -66
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/script/OP.js +3 -3
- package/dist/esm/src/script/OP.js.map +1 -1
- package/dist/esm/src/script/Script.js +12 -10
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/src/script/Spend.js +39 -32
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/script/templates/P2PKH.js +26 -11
- package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
- package/dist/esm/src/script/templates/PushDrop.js +29 -22
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/src/script/templates/RPuzzle.js +11 -6
- package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/esm/src/totp/totp.js +2 -1
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +176 -154
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefParty.js +24 -24
- package/dist/esm/src/transaction/BeefParty.js.map +1 -1
- package/dist/esm/src/transaction/BeefTx.js +26 -18
- package/dist/esm/src/transaction/BeefTx.js.map +1 -1
- package/dist/esm/src/transaction/Broadcaster.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js +61 -36
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +105 -138
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/ARC.js +25 -16
- package/dist/esm/src/transaction/broadcasters/ARC.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/esm/src/transaction/broadcasters/WhatsOnChainBroadcaster.js.map +1 -1
- package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js +3 -3
- package/dist/esm/src/transaction/chaintrackers/WhatsOnChain.js.map +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/esm/src/transaction/http/DefaultHttpClient.js +3 -2
- package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/FetchHttpClient.js +4 -2
- package/dist/esm/src/transaction/http/FetchHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/NodejsHttpClient.js +5 -3
- package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/index.js.map +1 -1
- package/dist/esm/src/transaction/index.js.map +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js +91 -66
- package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/KeyDeriver.js +60 -52
- package/dist/esm/src/wallet/KeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/ProtoWallet.js +75 -29
- package/dist/esm/src/wallet/ProtoWallet.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js +7 -2
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/WalletError.js +2 -2
- package/dist/esm/src/wallet/WalletError.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +4 -4
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +2 -2
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1239 -1261
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +95 -43
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +8 -3
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/src/wallet/substrates/window.CWI.js +28 -28
- package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +15 -15
- package/dist/types/src/auth/Peer.d.ts +10 -10
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/SessionManager.d.ts +4 -4
- package/dist/types/src/auth/SessionManager.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts +6 -6
- package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +5 -5
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +23 -22
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts +1 -1
- package/dist/types/src/auth/transports/SimplifiedFetchTransport.d.ts.map +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +3 -3
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/validateCertificates.d.ts +2 -2
- package/dist/types/src/auth/utils/validateCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
- package/dist/types/src/compat/BSM.d.ts +1 -1
- package/dist/types/src/compat/BSM.d.ts.map +1 -1
- package/dist/types/src/compat/ECIES.d.ts +36 -36
- package/dist/types/src/compat/ECIES.d.ts.map +1 -1
- package/dist/types/src/compat/HD.d.ts +51 -51
- package/dist/types/src/compat/HD.d.ts.map +1 -1
- package/dist/types/src/compat/Mnemonic.d.ts +79 -79
- package/dist/types/src/compat/Mnemonic.d.ts.map +1 -1
- package/dist/types/src/compat/Utxo.d.ts.map +1 -1
- package/dist/types/src/messages/EncryptedMessage.d.ts.map +1 -1
- package/dist/types/src/messages/SignedMessage.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +9 -9
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts +17 -17
- package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +14 -14
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
- package/dist/types/src/primitives/AESGCM.d.ts.map +1 -1
- package/dist/types/src/primitives/BasePoint.d.ts +8 -8
- package/dist/types/src/primitives/BasePoint.d.ts.map +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
- package/dist/types/src/primitives/Curve.d.ts +14 -7
- package/dist/types/src/primitives/Curve.d.ts.map +1 -1
- package/dist/types/src/primitives/DRBG.d.ts.map +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
- package/dist/types/src/primitives/Hash.d.ts +11 -11
- package/dist/types/src/primitives/Hash.d.ts.map +1 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts.map +1 -1
- package/dist/types/src/primitives/Point.d.ts +14 -10
- package/dist/types/src/primitives/Point.d.ts.map +1 -1
- package/dist/types/src/primitives/Polynomial.d.ts.map +1 -1
- package/dist/types/src/primitives/PrivateKey.d.ts +2 -2
- package/dist/types/src/primitives/PrivateKey.d.ts.map +1 -1
- package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
- package/dist/types/src/primitives/Random.d.ts.map +1 -1
- package/dist/types/src/primitives/Schnorr.d.ts +14 -14
- package/dist/types/src/primitives/Schnorr.d.ts.map +1 -1
- package/dist/types/src/primitives/Signature.d.ts +1 -1
- package/dist/types/src/primitives/Signature.d.ts.map +1 -1
- package/dist/types/src/primitives/SymmetricKey.d.ts +13 -13
- package/dist/types/src/primitives/SymmetricKey.d.ts.map +1 -1
- package/dist/types/src/primitives/TransactionSignature.d.ts +4 -4
- package/dist/types/src/primitives/TransactionSignature.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts +3 -6
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/script/Script.d.ts +3 -3
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/src/script/ScriptTemplate.d.ts +2 -2
- package/dist/types/src/script/ScriptTemplate.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
- package/dist/types/src/script/templates/PushDrop.d.ts +1 -2
- package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
- package/dist/types/src/script/templates/RPuzzle.d.ts.map +1 -1
- package/dist/types/src/totp/totp.d.ts.map +1 -1
- package/dist/types/src/transaction/Beef.d.ts +96 -96
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefParty.d.ts +22 -22
- package/dist/types/src/transaction/BeefParty.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefTx.d.ts +5 -5
- package/dist/types/src/transaction/BeefTx.d.ts.map +1 -1
- package/dist/types/src/transaction/Broadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/ChainTracker.d.ts +2 -2
- package/dist/types/src/transaction/FeeModel.d.ts.map +1 -1
- package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
- package/dist/types/src/transaction/Transaction.d.ts +4 -12
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/src/transaction/TransactionOutput.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/ARC.d.ts +1 -1
- package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/DefaultBroadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/broadcasters/WhatsOnChainBroadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/chaintrackers/DefaultChainTracker.d.ts.map +1 -1
- package/dist/types/src/transaction/chaintrackers/WhatsOnChain.d.ts.map +1 -1
- package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +1 -1
- package/dist/types/src/transaction/http/DefaultHttpClient.d.ts +1 -1
- package/dist/types/src/transaction/http/DefaultHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/FetchHttpClient.d.ts +5 -5
- package/dist/types/src/transaction/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/HttpClient.d.ts +4 -4
- package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/NodejsHttpClient.d.ts +3 -3
- package/dist/types/src/transaction/http/NodejsHttpClient.d.ts.map +1 -1
- package/dist/types/src/transaction/http/index.d.ts.map +1 -1
- package/dist/types/src/transaction/index.d.ts.map +1 -1
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts +58 -58
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts +78 -78
- package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/ProtoWallet.d.ts +10 -10
- package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -1
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +151 -152
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +5 -5
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +6 -6
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/window.CWI.d.ts +6 -6
- package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/auth.md +92 -82
- package/docs/compat.md +24 -24
- package/docs/messages.md +7 -5
- package/docs/overlay-tools.md +21 -21
- package/docs/primitives.md +336 -315
- package/docs/script.md +35 -35
- package/docs/swagger/dist/swagger-initializer.js +7 -7
- package/docs/swagger/dist/swagger-ui-bundle.js +1 -1
- package/docs/swagger/dist/swagger-ui-es-bundle-core.js +2 -2
- package/docs/swagger/dist/swagger-ui-es-bundle.js +1 -1
- package/docs/swagger/dist/swagger-ui-standalone-preset.js +1 -1
- package/docs/swagger/dist/swagger-ui.js +2 -2
- package/docs/totp.md +5 -5
- package/docs/transaction.md +103 -105
- package/docs/wallet-substrates.md +17 -17
- package/docs/wallet.md +202 -204
- package/mod.ts +15 -15
- package/package.json +15 -3
- package/src/auth/Peer.ts +271 -121
- package/src/auth/SessionManager.ts +17 -10
- package/src/auth/__tests/Peer.test.ts +361 -179
- package/src/auth/__tests/SessionManager.test.ts +67 -19
- package/src/auth/__tests/build.test.ts +11 -0
- package/src/auth/certificates/Certificate.ts +27 -14
- package/src/auth/certificates/MasterCertificate.ts +106 -62
- package/src/auth/certificates/VerifiableCertificate.ts +30 -8
- package/src/auth/certificates/__tests/Certificate.test.ts +32 -17
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +171 -68
- package/src/auth/certificates/__tests/MasterCertificate.test.ts +63 -47
- package/src/auth/certificates/__tests/VerifiableCertificate.test.ts +42 -31
- package/src/auth/certificates/index.ts +1 -1
- package/src/auth/clients/AuthFetch.ts +1 -0
- package/src/auth/clients/index.ts +1 -1
- package/src/auth/transports/SimplifiedFetchTransport.ts +145 -72
- package/src/auth/transports/index.ts +1 -1
- package/src/auth/utils/__tests/cryptononce.test.ts +52 -23
- package/src/auth/utils/__tests/getVerifiableCertificates.test.ts +56 -30
- package/src/auth/utils/__tests/validateCertificates.test.ts +53 -31
- package/src/auth/utils/createNonce.ts +11 -3
- package/src/auth/utils/getVerifiableCertificates.ts +12 -7
- package/src/auth/utils/validateCertificates.ts +57 -39
- package/src/auth/utils/verifyNonce.ts +6 -2
- package/src/compat/BSM.ts +10 -2
- package/src/compat/ECIES.ts +265 -141
- package/src/compat/HD.ts +81 -63
- package/src/compat/Mnemonic.ts +104 -91
- package/src/compat/Utxo.ts +8 -5
- package/src/compat/__tests/BSM.test.ts +42 -16
- package/src/compat/__tests/ECIES.test.ts +117 -52
- package/src/compat/__tests/HD.test.ts +55 -42
- package/src/compat/__tests/Mnemonic.test.ts +11 -12
- package/src/compat/__tests/Mnemonic.vectors.ts +110 -55
- package/src/messages/EncryptedMessage.ts +6 -2
- package/src/messages/SignedMessage.ts +14 -8
- package/src/messages/__tests/EncryptedMessage.test.ts +23 -24
- package/src/messages/__tests/SignedMessage.test.ts +17 -11
- package/src/overlay-tools/LookupResolver.ts +108 -56
- package/src/overlay-tools/OverlayAdminTokenTemplate.ts +52 -23
- package/src/overlay-tools/SHIPBroadcaster.ts +135 -59
- package/src/overlay-tools/__tests/LookupResolver.test.ts +723 -323
- package/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.ts +50 -22
- package/src/overlay-tools/__tests/SHIPBroadcaster.test.ts +607 -290
- package/src/primitives/AESGCM.ts +2 -0
- package/src/primitives/BasePoint.ts +4 -4
- package/src/primitives/BigNumber.ts +99 -90
- package/src/primitives/Curve.ts +117 -46
- package/src/primitives/DRBG.ts +9 -11
- package/src/primitives/ECDSA.ts +109 -63
- package/src/primitives/Hash.ts +492 -321
- package/src/primitives/JacobianPoint.ts +67 -19
- package/src/primitives/Point.ts +254 -152
- package/src/primitives/Polynomial.ts +8 -3
- package/src/primitives/PrivateKey.ts +41 -17
- package/src/primitives/PublicKey.ts +13 -3
- package/src/primitives/Random.ts +14 -8
- package/src/primitives/ReductionContext.ts +1 -1
- package/src/primitives/Schnorr.ts +40 -18
- package/src/primitives/Signature.ts +26 -16
- package/src/primitives/SymmetricKey.ts +14 -14
- package/src/primitives/TransactionSignature.ts +41 -17
- package/src/primitives/__tests/AESGCM.test.ts +457 -151
- package/src/primitives/__tests/BRC42.private.vectors.ts +30 -15
- package/src/primitives/__tests/BRC42.public.vectors.ts +30 -15
- package/src/primitives/__tests/BigNumber.arithmatic.test.ts +344 -125
- package/src/primitives/__tests/BigNumber.binary.test.ts +148 -67
- package/src/primitives/__tests/BigNumber.constructor.test.ts +65 -25
- package/src/primitives/__tests/BigNumber.dhGroup.test.ts +15 -11
- package/src/primitives/__tests/BigNumber.fixtures.ts +16 -8
- package/src/primitives/__tests/BigNumber.serializers.test.ts +41 -15
- package/src/primitives/__tests/BigNumber.utils.test.ts +132 -42
- package/src/primitives/__tests/Curve.unit.test.ts +75 -53
- package/src/primitives/__tests/DRBG.test.ts +1 -1
- package/src/primitives/__tests/DRBG.vectors.ts +45 -75
- package/src/primitives/__tests/ECDH.test.ts +15 -8
- package/src/primitives/__tests/ECDSA.test.ts +12 -6
- package/src/primitives/__tests/HMAC.test.ts +24 -18
- package/src/primitives/__tests/Hash.test.ts +57 -46
- package/src/primitives/__tests/PBKDF2.vectors.ts +130 -117
- package/src/primitives/__tests/PrivateKey.split.test.ts +33 -11
- package/src/primitives/__tests/PrivateKey.test.ts +11 -10
- package/src/primitives/__tests/PublicKey.test.ts +64 -53
- package/src/primitives/__tests/Random.test.ts +1 -1
- package/src/primitives/__tests/Reader.test.ts +240 -219
- package/src/primitives/__tests/ReductionContext.test.ts +98 -61
- package/src/primitives/__tests/Schnorr.test.ts +249 -237
- package/src/primitives/__tests/SymmetricKey.test.ts +18 -15
- package/src/primitives/__tests/SymmetricKey.vectors.ts +16 -8
- package/src/primitives/__tests/Writer.test.ts +23 -13
- package/src/primitives/__tests/bug-31.test.ts +6 -10
- package/src/primitives/__tests/utils.test.ts +70 -19
- package/src/primitives/utils.ts +103 -79
- package/src/script/Script.ts +18 -12
- package/src/script/ScriptTemplate.ts +3 -5
- package/src/script/Spend.ts +306 -108
- package/src/script/__tests/Script.test.ts +73 -55
- package/src/script/__tests/Spend.test.ts +208 -83
- package/src/script/__tests/SpendComplex.test.ts +19 -13
- package/src/script/__tests/script.invalid.vectors.ts +428 -1796
- package/src/script/__tests/script.valid.vectors.ts +728 -2764
- package/src/script/templates/P2PKH.ts +34 -12
- package/src/script/templates/PushDrop.ts +65 -31
- package/src/script/templates/RPuzzle.ts +29 -8
- package/src/script/templates/__tests/PushDrop.test.ts +146 -41
- package/src/totp/__tests/totp.test.ts +45 -44
- package/src/totp/totp.ts +3 -2
- package/src/transaction/Beef.ts +269 -174
- package/src/transaction/BeefParty.ts +41 -31
- package/src/transaction/BeefTx.ts +36 -26
- package/src/transaction/Broadcaster.ts +10 -6
- package/src/transaction/ChainTracker.ts +2 -2
- package/src/transaction/FeeModel.ts +0 -1
- package/src/transaction/MerklePath.ts +124 -59
- package/src/transaction/Transaction.ts +188 -187
- package/src/transaction/TransactionOutput.ts +0 -1
- package/src/transaction/__tests/Beef.test.ts +390 -287
- package/src/transaction/__tests/MerklePath.test.ts +59 -26
- package/src/transaction/__tests/Transaction.benchmarks.test.ts +231 -201
- package/src/transaction/__tests/Transaction.test.ts +758 -482
- package/src/transaction/__tests/bigtx.vectors.ts +2 -1
- package/src/transaction/__tests/bump.invalid.vectors.ts +24 -6
- package/src/transaction/__tests/bump.valid.vectors.ts +6 -2
- package/src/transaction/__tests/tx.invalid.vectors.ts +881 -185
- package/src/transaction/__tests/tx.valid.vectors.ts +1210 -257
- package/src/transaction/broadcasters/ARC.ts +69 -38
- package/src/transaction/broadcasters/DefaultBroadcaster.ts +9 -3
- package/src/transaction/broadcasters/WhatsOnChainBroadcaster.ts +20 -7
- package/src/transaction/broadcasters/__tests/ARC.test.ts +127 -59
- package/src/transaction/broadcasters/__tests/WhatsOnChainBroadcaster.test.ts +27 -18
- package/src/transaction/chaintrackers/DefaultChainTracker.ts +1 -1
- package/src/transaction/chaintrackers/WhatsOnChain.ts +27 -11
- package/src/transaction/chaintrackers/__tests/WhatsOnChainChainTracker.test.ts +59 -23
- package/src/transaction/fee-models/SatoshisPerKilobyte.ts +9 -5
- package/src/transaction/http/DefaultHttpClient.ts +5 -4
- package/src/transaction/http/FetchHttpClient.ts +18 -9
- package/src/transaction/http/HttpClient.ts +27 -22
- package/src/transaction/http/NodejsHttpClient.ts +23 -9
- package/src/transaction/http/index.ts +5 -1
- package/src/transaction/index.ts +5 -1
- package/src/wallet/CachedKeyDeriver.ts +151 -82
- package/src/wallet/KeyDeriver.ts +186 -105
- package/src/wallet/ProtoWallet.ts +121 -52
- package/src/wallet/Wallet.interfaces.ts +167 -156
- package/src/wallet/WalletClient.ts +314 -59
- package/src/wallet/WalletError.ts +2 -2
- package/src/wallet/__tests/CachedKeyDeriver.test.ts +86 -27
- package/src/wallet/__tests/KeyDeriver.test.ts +136 -33
- package/src/wallet/__tests/ProtoWallet.test.ts +190 -102
- package/src/wallet/substrates/HTTPWalletJSON.ts +250 -67
- package/src/wallet/substrates/HTTPWalletWire.ts +7 -3
- package/src/wallet/substrates/WalletWireCalls.ts +2 -2
- package/src/wallet/substrates/WalletWireProcessor.ts +1412 -1277
- package/src/wallet/substrates/WalletWireTransceiver.ts +713 -138
- package/src/wallet/substrates/XDM.ts +425 -36
- package/src/wallet/substrates/__tests/WalletWire.integration.test.ts +488 -225
- package/src/wallet/substrates/__tests/XDM.test.ts +232 -234
- package/src/wallet/substrates/window.CWI.ts +520 -61
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import SHIPCast from '
|
|
2
|
-
import LookupResolver from '
|
|
3
|
-
import { PrivateKey } from '
|
|
4
|
-
import { Transaction } from '
|
|
5
|
-
import OverlayAdminTokenTemplate from '
|
|
6
|
-
import
|
|
1
|
+
import SHIPCast from '../../overlay-tools/SHIPBroadcaster'
|
|
2
|
+
import LookupResolver from '../../overlay-tools/LookupResolver'
|
|
3
|
+
import { PrivateKey } from '../../primitives/index'
|
|
4
|
+
import { Transaction } from '../../transaction/index'
|
|
5
|
+
import OverlayAdminTokenTemplate from '../../overlay-tools/OverlayAdminTokenTemplate'
|
|
6
|
+
import { CompletedProtoWallet } from '../../auth/certificates/__tests/CompletedProtoWallet'
|
|
7
7
|
|
|
8
8
|
const mockFacilitator = {
|
|
9
9
|
send: jest.fn()
|
|
@@ -20,33 +20,49 @@ describe('SHIPCast', () => {
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
it('Handles constructor errors', () => {
|
|
23
|
-
expect(() => new SHIPCast([])).toThrow(
|
|
24
|
-
|
|
23
|
+
expect(() => new SHIPCast([])).toThrow(
|
|
24
|
+
new Error('At least one topic is required for broadcast.')
|
|
25
|
+
)
|
|
26
|
+
expect(() => new SHIPCast(['badprefix_foo'])).toThrow(
|
|
27
|
+
new Error('Every topic must start with "tm_".')
|
|
28
|
+
)
|
|
25
29
|
})
|
|
26
30
|
|
|
27
31
|
it('should broadcast to a single SHIP host found via resolver', async () => {
|
|
28
32
|
const shipHostKey = new PrivateKey(42)
|
|
29
|
-
const shipWallet = new
|
|
33
|
+
const shipWallet = new CompletedProtoWallet(shipHostKey)
|
|
30
34
|
const shipLib = new OverlayAdminTokenTemplate(shipWallet)
|
|
31
|
-
const shipScript = await shipLib.lock(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const shipScript = await shipLib.lock(
|
|
36
|
+
'SHIP',
|
|
37
|
+
'https://shiphost.com',
|
|
38
|
+
'tm_foo'
|
|
39
|
+
)
|
|
40
|
+
const shipTx = new Transaction(
|
|
41
|
+
1,
|
|
42
|
+
[],
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
lockingScript: shipScript,
|
|
46
|
+
satoshis: 1
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
0
|
|
50
|
+
)
|
|
36
51
|
|
|
37
52
|
// Resolver returns one host interested in 'tm_foo' topic
|
|
38
53
|
mockResolver.query.mockReturnValueOnce({
|
|
39
54
|
type: 'output-list',
|
|
40
|
-
outputs: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
outputs: [
|
|
56
|
+
{
|
|
57
|
+
beef: shipTx.toBEEF(),
|
|
58
|
+
outputIndex: 0
|
|
59
|
+
}
|
|
60
|
+
]
|
|
44
61
|
})
|
|
45
62
|
|
|
46
63
|
// Host responds successfully
|
|
47
64
|
mockFacilitator.send.mockReturnValueOnce({
|
|
48
65
|
tm_foo: {
|
|
49
|
-
|
|
50
66
|
outputsToAdmit: [0],
|
|
51
67
|
coinsToRetain: []
|
|
52
68
|
}
|
|
@@ -65,12 +81,15 @@ describe('SHIPCast', () => {
|
|
|
65
81
|
message: 'Sent to 1 Overlay Services host.'
|
|
66
82
|
})
|
|
67
83
|
|
|
68
|
-
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
85
|
+
{
|
|
86
|
+
service: 'ls_ship',
|
|
87
|
+
query: {
|
|
88
|
+
topics: ['tm_foo']
|
|
89
|
+
}
|
|
72
90
|
},
|
|
73
|
-
|
|
91
|
+
1000
|
|
92
|
+
)
|
|
74
93
|
|
|
75
94
|
expect(mockFacilitator.send).toHaveBeenCalledWith('https://shiphost.com', {
|
|
76
95
|
beef: testTx.toBEEF(),
|
|
@@ -80,34 +99,59 @@ describe('SHIPCast', () => {
|
|
|
80
99
|
|
|
81
100
|
it('should be resilient to malformed or corrupted SHIP data, to the extent possible', async () => {
|
|
82
101
|
const shipHostKey = new PrivateKey(42)
|
|
83
|
-
const shipWallet = new
|
|
102
|
+
const shipWallet = new CompletedProtoWallet(shipHostKey)
|
|
84
103
|
const shipLib = new OverlayAdminTokenTemplate(shipWallet)
|
|
85
104
|
// First SHIP is for wrong topic
|
|
86
|
-
const shipScript = await shipLib.lock(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
const shipScript = await shipLib.lock(
|
|
106
|
+
'SHIP',
|
|
107
|
+
'https://shiphost.com',
|
|
108
|
+
'tm_wrong'
|
|
109
|
+
)
|
|
110
|
+
const shipTx = new Transaction(
|
|
111
|
+
1,
|
|
112
|
+
[],
|
|
113
|
+
[
|
|
114
|
+
{
|
|
115
|
+
lockingScript: shipScript,
|
|
116
|
+
satoshis: 1
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
0
|
|
120
|
+
)
|
|
91
121
|
const shipHostKey2 = new PrivateKey(43)
|
|
92
|
-
const shipWallet2 = new
|
|
122
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
93
123
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
94
124
|
// Second SHIP is for correct topic
|
|
95
|
-
const shipScript2 = await shipLib2.lock(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
const shipScript2 = await shipLib2.lock(
|
|
126
|
+
'SHIP',
|
|
127
|
+
'https://shiphost2.com',
|
|
128
|
+
'tm_foo'
|
|
129
|
+
)
|
|
130
|
+
const shipTx2 = new Transaction(
|
|
131
|
+
1,
|
|
132
|
+
[],
|
|
133
|
+
[
|
|
134
|
+
{
|
|
135
|
+
lockingScript: shipScript2,
|
|
136
|
+
satoshis: 1
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
0
|
|
140
|
+
)
|
|
100
141
|
|
|
101
142
|
// Resolver returns two hosts, both the correct and the corrupted ones.
|
|
102
143
|
mockResolver.query.mockReturnValueOnce({
|
|
103
144
|
type: 'output-list',
|
|
104
|
-
outputs: [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
outputs: [
|
|
146
|
+
{
|
|
147
|
+
beef: shipTx.toBEEF(),
|
|
148
|
+
outputIndex: 0
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
beef: shipTx2.toBEEF(),
|
|
152
|
+
outputIndex: 0
|
|
153
|
+
}
|
|
154
|
+
]
|
|
111
155
|
})
|
|
112
156
|
|
|
113
157
|
// Host responds successfully
|
|
@@ -147,7 +191,9 @@ describe('SHIPCast', () => {
|
|
|
147
191
|
different: 'structure'
|
|
148
192
|
}
|
|
149
193
|
})
|
|
150
|
-
await expect(async () => await b.broadcast(testTx)).rejects.toThrow(
|
|
194
|
+
await expect(async () => await b.broadcast(testTx)).rejects.toThrow(
|
|
195
|
+
'SHIP answer is not an output list.'
|
|
196
|
+
)
|
|
151
197
|
expect(mockFacilitator.send).not.toHaveBeenCalled()
|
|
152
198
|
|
|
153
199
|
// Resolver returns the wrong output structure
|
|
@@ -157,25 +203,32 @@ describe('SHIPCast', () => {
|
|
|
157
203
|
different: 'structure'
|
|
158
204
|
}
|
|
159
205
|
})
|
|
160
|
-
await expect(async () => await b.broadcast(testTx)).rejects.toThrow(
|
|
206
|
+
await expect(async () => await b.broadcast(testTx)).rejects.toThrow(
|
|
207
|
+
'answer.outputs is not iterable'
|
|
208
|
+
)
|
|
161
209
|
expect(mockFacilitator.send).not.toHaveBeenCalled()
|
|
162
210
|
|
|
163
211
|
// Resolver returns corrupted BEEF alongside good data
|
|
164
212
|
mockResolver.query.mockReturnValueOnce({
|
|
165
213
|
type: 'output-list',
|
|
166
|
-
outputs: [
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
214
|
+
outputs: [
|
|
215
|
+
{
|
|
216
|
+
beef: shipTx.toBEEF(), // Wrong topic
|
|
217
|
+
outputIndex: 0
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
beef: [0], // corrupted "rotten" BEEF
|
|
221
|
+
outputIndex: 4
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
beef: shipTx2.toBEEF(),
|
|
225
|
+
outputIndex: 1 // Wrong output index
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
beef: shipTx2.toBEEF(),
|
|
229
|
+
outputIndex: 0 // correct
|
|
230
|
+
}
|
|
231
|
+
]
|
|
179
232
|
})
|
|
180
233
|
response = await b.broadcast(testTx)
|
|
181
234
|
expect(response).toEqual({
|
|
@@ -203,7 +256,9 @@ describe('SHIPCast', () => {
|
|
|
203
256
|
}
|
|
204
257
|
} as unknown as Transaction
|
|
205
258
|
|
|
206
|
-
await expect(b.broadcast(testTx)).rejects.toThrow(
|
|
259
|
+
await expect(b.broadcast(testTx)).rejects.toThrow(
|
|
260
|
+
'Transactions sent via SHIP to Overlay Services must be serializable to BEEF format.'
|
|
261
|
+
)
|
|
207
262
|
})
|
|
208
263
|
|
|
209
264
|
it('should fail when no hosts are interested in the topics', async () => {
|
|
@@ -227,33 +282,49 @@ describe('SHIPCast', () => {
|
|
|
227
282
|
description: 'No hosts are interested in receiving this transaction.'
|
|
228
283
|
})
|
|
229
284
|
|
|
230
|
-
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
285
|
+
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
286
|
+
{
|
|
287
|
+
service: 'ls_ship',
|
|
288
|
+
query: {
|
|
289
|
+
topics: ['tm_foo']
|
|
290
|
+
}
|
|
234
291
|
},
|
|
235
|
-
|
|
292
|
+
1000
|
|
293
|
+
)
|
|
236
294
|
|
|
237
295
|
expect(mockFacilitator.send).not.toHaveBeenCalled()
|
|
238
296
|
})
|
|
239
297
|
|
|
240
298
|
it('should fail when all hosts reject the transaction', async () => {
|
|
241
299
|
const shipHostKey = new PrivateKey(42)
|
|
242
|
-
const shipWallet = new
|
|
300
|
+
const shipWallet = new CompletedProtoWallet(shipHostKey)
|
|
243
301
|
const shipLib = new OverlayAdminTokenTemplate(shipWallet)
|
|
244
|
-
const shipScript = await shipLib.lock(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
302
|
+
const shipScript = await shipLib.lock(
|
|
303
|
+
'SHIP',
|
|
304
|
+
'https://shiphost.com',
|
|
305
|
+
'tm_foo'
|
|
306
|
+
)
|
|
307
|
+
const shipTx = new Transaction(
|
|
308
|
+
1,
|
|
309
|
+
[],
|
|
310
|
+
[
|
|
311
|
+
{
|
|
312
|
+
lockingScript: shipScript,
|
|
313
|
+
satoshis: 1
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
0
|
|
317
|
+
)
|
|
249
318
|
|
|
250
319
|
// Resolver returns one host
|
|
251
320
|
mockResolver.query.mockReturnValueOnce({
|
|
252
321
|
type: 'output-list',
|
|
253
|
-
outputs: [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
322
|
+
outputs: [
|
|
323
|
+
{
|
|
324
|
+
beef: shipTx.toBEEF(),
|
|
325
|
+
outputIndex: 0
|
|
326
|
+
}
|
|
327
|
+
]
|
|
257
328
|
})
|
|
258
329
|
|
|
259
330
|
// Host fails
|
|
@@ -280,34 +351,49 @@ describe('SHIPCast', () => {
|
|
|
280
351
|
|
|
281
352
|
it('should fail when required specific hosts are not among interested hosts', async () => {
|
|
282
353
|
const shipHostKey = new PrivateKey(42)
|
|
283
|
-
const shipWallet = new
|
|
354
|
+
const shipWallet = new CompletedProtoWallet(shipHostKey)
|
|
284
355
|
const shipLib = new OverlayAdminTokenTemplate(shipWallet)
|
|
285
|
-
const shipScript = await shipLib.lock(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
356
|
+
const shipScript = await shipLib.lock(
|
|
357
|
+
'SHIP',
|
|
358
|
+
'https://shiphost.com',
|
|
359
|
+
'tm_foo'
|
|
360
|
+
)
|
|
361
|
+
const shipTx = new Transaction(
|
|
362
|
+
1,
|
|
363
|
+
[],
|
|
364
|
+
[
|
|
365
|
+
{
|
|
366
|
+
lockingScript: shipScript,
|
|
367
|
+
satoshis: 1
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
0
|
|
371
|
+
)
|
|
290
372
|
|
|
291
373
|
// Resolver returns one host
|
|
292
374
|
mockResolver.query.mockReturnValueOnce({
|
|
293
375
|
type: 'output-list',
|
|
294
|
-
outputs: [
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
376
|
+
outputs: [
|
|
377
|
+
{
|
|
378
|
+
beef: shipTx.toBEEF(),
|
|
379
|
+
outputIndex: 0
|
|
380
|
+
}
|
|
381
|
+
]
|
|
298
382
|
})
|
|
299
383
|
|
|
300
384
|
// First host acknowledges 'tm_foo', but it's not the right host.
|
|
301
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
385
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
386
|
+
async (host, { beef, topics }) => {
|
|
387
|
+
const steak = {}
|
|
388
|
+
for (const topic of topics) {
|
|
389
|
+
steak[topic] = {
|
|
390
|
+
outputsToAdmit: topic === 'tm_foo' ? [0] : [],
|
|
391
|
+
coinsToRetain: []
|
|
392
|
+
}
|
|
307
393
|
}
|
|
394
|
+
return steak
|
|
308
395
|
}
|
|
309
|
-
|
|
310
|
-
})
|
|
396
|
+
)
|
|
311
397
|
|
|
312
398
|
const b = new SHIPCast(['tm_foo'], {
|
|
313
399
|
facilitator: mockFacilitator,
|
|
@@ -330,30 +416,62 @@ describe('SHIPCast', () => {
|
|
|
330
416
|
|
|
331
417
|
it('should succeed when all hosts acknowledge all topics (default behavior)', async () => {
|
|
332
418
|
const shipHostKey1 = new PrivateKey(42)
|
|
333
|
-
const shipWallet1 = new
|
|
419
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
334
420
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
335
|
-
const shipScript1 = await shipLib1.lock(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
421
|
+
const shipScript1 = await shipLib1.lock(
|
|
422
|
+
'SHIP',
|
|
423
|
+
'https://shiphost1.com',
|
|
424
|
+
'tm_foo'
|
|
425
|
+
)
|
|
426
|
+
const shipScript1b = await shipLib1.lock(
|
|
427
|
+
'SHIP',
|
|
428
|
+
'https://shiphost1.com',
|
|
429
|
+
'tm_bar'
|
|
430
|
+
)
|
|
431
|
+
const shipTx1 = new Transaction(
|
|
432
|
+
1,
|
|
433
|
+
[],
|
|
434
|
+
[
|
|
435
|
+
{
|
|
436
|
+
lockingScript: shipScript1,
|
|
437
|
+
satoshis: 1
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
lockingScript: shipScript1b,
|
|
441
|
+
satoshis: 1
|
|
442
|
+
}
|
|
443
|
+
],
|
|
444
|
+
0
|
|
445
|
+
)
|
|
344
446
|
|
|
345
447
|
const shipHostKey2 = new PrivateKey(43)
|
|
346
|
-
const shipWallet2 = new
|
|
448
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
347
449
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
348
|
-
const shipScript2 = await shipLib2.lock(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
450
|
+
const shipScript2 = await shipLib2.lock(
|
|
451
|
+
'SHIP',
|
|
452
|
+
'https://shiphost2.com',
|
|
453
|
+
'tm_bar'
|
|
454
|
+
)
|
|
455
|
+
const shipScript2b = await shipLib2.lock(
|
|
456
|
+
'SHIP',
|
|
457
|
+
'https://shiphost2.com',
|
|
458
|
+
'tm_foo'
|
|
459
|
+
)
|
|
460
|
+
const shipTx2 = new Transaction(
|
|
461
|
+
1,
|
|
462
|
+
[],
|
|
463
|
+
[
|
|
464
|
+
{
|
|
465
|
+
lockingScript: shipScript2,
|
|
466
|
+
satoshis: 1
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
lockingScript: shipScript2b,
|
|
470
|
+
satoshis: 1
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
0
|
|
474
|
+
)
|
|
357
475
|
|
|
358
476
|
// Resolver returns two hosts
|
|
359
477
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -391,34 +509,59 @@ describe('SHIPCast', () => {
|
|
|
391
509
|
message: 'Sent to 2 Overlay Services hosts.'
|
|
392
510
|
})
|
|
393
511
|
|
|
394
|
-
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
512
|
+
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
513
|
+
{
|
|
514
|
+
service: 'ls_ship',
|
|
515
|
+
query: {
|
|
516
|
+
topics: ['tm_foo', 'tm_bar']
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
1000
|
|
520
|
+
)
|
|
400
521
|
|
|
401
522
|
expect(mockFacilitator.send).toHaveBeenCalledTimes(2)
|
|
402
523
|
})
|
|
403
524
|
|
|
404
525
|
it('should fail if at least one host does not acknowledge every topic (default behavior)', async () => {
|
|
405
526
|
const shipHostKey1 = new PrivateKey(42)
|
|
406
|
-
const shipWallet1 = new
|
|
527
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
407
528
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
408
|
-
const shipScript1 = await shipLib1.lock(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
529
|
+
const shipScript1 = await shipLib1.lock(
|
|
530
|
+
'SHIP',
|
|
531
|
+
'https://shiphost1.com',
|
|
532
|
+
'tm_foo'
|
|
533
|
+
)
|
|
534
|
+
const shipTx1 = new Transaction(
|
|
535
|
+
1,
|
|
536
|
+
[],
|
|
537
|
+
[
|
|
538
|
+
{
|
|
539
|
+
lockingScript: shipScript1,
|
|
540
|
+
satoshis: 1
|
|
541
|
+
}
|
|
542
|
+
],
|
|
543
|
+
0
|
|
544
|
+
)
|
|
413
545
|
|
|
414
546
|
const shipHostKey2 = new PrivateKey(43)
|
|
415
|
-
const shipWallet2 = new
|
|
547
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
416
548
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
417
|
-
const shipScript2 = await shipLib2.lock(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
549
|
+
const shipScript2 = await shipLib2.lock(
|
|
550
|
+
'SHIP',
|
|
551
|
+
'https://shiphost2.com',
|
|
552
|
+
'tm_bar'
|
|
553
|
+
)
|
|
554
|
+
const shipTx2 = new Transaction(
|
|
555
|
+
1,
|
|
556
|
+
[],
|
|
557
|
+
[
|
|
558
|
+
{
|
|
559
|
+
lockingScript: shipScript2,
|
|
560
|
+
satoshis: 1
|
|
561
|
+
}
|
|
562
|
+
],
|
|
563
|
+
0
|
|
564
|
+
)
|
|
422
565
|
|
|
423
566
|
// Resolver returns two hosts
|
|
424
567
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -430,28 +573,32 @@ describe('SHIPCast', () => {
|
|
|
430
573
|
})
|
|
431
574
|
|
|
432
575
|
// First host acknowledges 'tm_foo'
|
|
433
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
576
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
577
|
+
async (host, { beef, topics }) => {
|
|
578
|
+
const steak = {}
|
|
579
|
+
for (const topic of topics) {
|
|
580
|
+
steak[topic] = {
|
|
581
|
+
outputsToAdmit: [],
|
|
582
|
+
coinsToRetain: []
|
|
583
|
+
}
|
|
439
584
|
}
|
|
585
|
+
return steak
|
|
440
586
|
}
|
|
441
|
-
|
|
442
|
-
})
|
|
587
|
+
)
|
|
443
588
|
|
|
444
589
|
// Second host does not acknowledge any topics
|
|
445
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
590
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
591
|
+
async (host, { beef, topics }) => {
|
|
592
|
+
const steak = {}
|
|
593
|
+
for (const topic of topics) {
|
|
594
|
+
steak[topic] = {
|
|
595
|
+
outputsToAdmit: [],
|
|
596
|
+
coinsToRetain: []
|
|
597
|
+
}
|
|
451
598
|
}
|
|
599
|
+
return steak
|
|
452
600
|
}
|
|
453
|
-
|
|
454
|
-
})
|
|
601
|
+
)
|
|
455
602
|
|
|
456
603
|
const b = new SHIPCast(['tm_foo', 'tm_bar'], {
|
|
457
604
|
facilitator: mockFacilitator,
|
|
@@ -469,22 +616,44 @@ describe('SHIPCast', () => {
|
|
|
469
616
|
|
|
470
617
|
it('should succeed when at least one host acknowledges required topics with requireAcknowledgmentFromAnyHostForTopics set to "any"', async () => {
|
|
471
618
|
const shipHostKey1 = new PrivateKey(42)
|
|
472
|
-
const shipWallet1 = new
|
|
619
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
473
620
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
474
|
-
const shipScript1 = await shipLib1.lock(
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
621
|
+
const shipScript1 = await shipLib1.lock(
|
|
622
|
+
'SHIP',
|
|
623
|
+
'https://shiphost1.com',
|
|
624
|
+
'tm_foo'
|
|
625
|
+
)
|
|
626
|
+
const shipTx1 = new Transaction(
|
|
627
|
+
1,
|
|
628
|
+
[],
|
|
629
|
+
[
|
|
630
|
+
{
|
|
631
|
+
lockingScript: shipScript1,
|
|
632
|
+
satoshis: 1
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
0
|
|
636
|
+
)
|
|
479
637
|
|
|
480
638
|
const shipHostKey2 = new PrivateKey(43)
|
|
481
|
-
const shipWallet2 = new
|
|
639
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
482
640
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
483
|
-
const shipScript2 = await shipLib2.lock(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
641
|
+
const shipScript2 = await shipLib2.lock(
|
|
642
|
+
'SHIP',
|
|
643
|
+
'https://shiphost2.com',
|
|
644
|
+
'tm_bar'
|
|
645
|
+
)
|
|
646
|
+
const shipTx2 = new Transaction(
|
|
647
|
+
1,
|
|
648
|
+
[],
|
|
649
|
+
[
|
|
650
|
+
{
|
|
651
|
+
lockingScript: shipScript2,
|
|
652
|
+
satoshis: 1
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
0
|
|
656
|
+
)
|
|
488
657
|
|
|
489
658
|
// Resolver returns two hosts
|
|
490
659
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -496,28 +665,32 @@ describe('SHIPCast', () => {
|
|
|
496
665
|
})
|
|
497
666
|
|
|
498
667
|
// First host acknowledges no topics
|
|
499
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
668
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
669
|
+
async (host, { beef, topics }) => {
|
|
670
|
+
const steak = {}
|
|
671
|
+
for (const topic of topics) {
|
|
672
|
+
steak[topic] = {
|
|
673
|
+
outputsToAdmit: [],
|
|
674
|
+
coinsToRetain: []
|
|
675
|
+
}
|
|
505
676
|
}
|
|
677
|
+
return steak
|
|
506
678
|
}
|
|
507
|
-
|
|
508
|
-
})
|
|
679
|
+
)
|
|
509
680
|
|
|
510
681
|
// Second host acknowledges 'tm_bar'
|
|
511
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
682
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
683
|
+
async (host, { beef, topics }) => {
|
|
684
|
+
const steak = {}
|
|
685
|
+
for (const topic of topics) {
|
|
686
|
+
steak[topic] = {
|
|
687
|
+
outputsToAdmit: topic === 'tm_bar' ? [0] : [],
|
|
688
|
+
coinsToRetain: []
|
|
689
|
+
}
|
|
517
690
|
}
|
|
691
|
+
return steak
|
|
518
692
|
}
|
|
519
|
-
|
|
520
|
-
})
|
|
693
|
+
)
|
|
521
694
|
|
|
522
695
|
const b = new SHIPCast(['tm_foo', 'tm_bar'], {
|
|
523
696
|
facilitator: mockFacilitator,
|
|
@@ -538,13 +711,24 @@ describe('SHIPCast', () => {
|
|
|
538
711
|
|
|
539
712
|
it('should fail when no hosts acknowledge required topics with requireAcknowledgmentFromAnyHostForTopics set to "any"', async () => {
|
|
540
713
|
const shipHostKey1 = new PrivateKey(42)
|
|
541
|
-
const shipWallet1 = new
|
|
714
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
542
715
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
543
|
-
const shipScript1 = await shipLib1.lock(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
716
|
+
const shipScript1 = await shipLib1.lock(
|
|
717
|
+
'SHIP',
|
|
718
|
+
'https://shiphost1.com',
|
|
719
|
+
'tm_foo'
|
|
720
|
+
)
|
|
721
|
+
const shipTx1 = new Transaction(
|
|
722
|
+
1,
|
|
723
|
+
[],
|
|
724
|
+
[
|
|
725
|
+
{
|
|
726
|
+
lockingScript: shipScript1,
|
|
727
|
+
satoshis: 1
|
|
728
|
+
}
|
|
729
|
+
],
|
|
730
|
+
0
|
|
731
|
+
)
|
|
548
732
|
|
|
549
733
|
// Resolver returns one host
|
|
550
734
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -553,16 +737,18 @@ describe('SHIPCast', () => {
|
|
|
553
737
|
})
|
|
554
738
|
|
|
555
739
|
// Host acknowledges no topics
|
|
556
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
740
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
741
|
+
async (host, { beef, topics }) => {
|
|
742
|
+
const steak = {}
|
|
743
|
+
for (const topic of topics) {
|
|
744
|
+
steak[topic] = {
|
|
745
|
+
outputsToAdmit: [],
|
|
746
|
+
coinsToRetain: []
|
|
747
|
+
}
|
|
562
748
|
}
|
|
749
|
+
return steak
|
|
563
750
|
}
|
|
564
|
-
|
|
565
|
-
})
|
|
751
|
+
)
|
|
566
752
|
|
|
567
753
|
const b = new SHIPCast(['tm_foo'], {
|
|
568
754
|
facilitator: mockFacilitator,
|
|
@@ -583,22 +769,44 @@ describe('SHIPCast', () => {
|
|
|
583
769
|
|
|
584
770
|
it('should succeed when specific hosts acknowledge required topics', async () => {
|
|
585
771
|
const shipHostKey1 = new PrivateKey(42)
|
|
586
|
-
const shipWallet1 = new
|
|
772
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
587
773
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
588
|
-
const shipScript1 = await shipLib1.lock(
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
774
|
+
const shipScript1 = await shipLib1.lock(
|
|
775
|
+
'SHIP',
|
|
776
|
+
'https://shiphost1.com',
|
|
777
|
+
'tm_foo'
|
|
778
|
+
)
|
|
779
|
+
const shipTx1 = new Transaction(
|
|
780
|
+
1,
|
|
781
|
+
[],
|
|
782
|
+
[
|
|
783
|
+
{
|
|
784
|
+
lockingScript: shipScript1,
|
|
785
|
+
satoshis: 1
|
|
786
|
+
}
|
|
787
|
+
],
|
|
788
|
+
0
|
|
789
|
+
)
|
|
593
790
|
|
|
594
791
|
const shipHostKey2 = new PrivateKey(43)
|
|
595
|
-
const shipWallet2 = new
|
|
792
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
596
793
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
597
|
-
const shipScript2 = await shipLib2.lock(
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
794
|
+
const shipScript2 = await shipLib2.lock(
|
|
795
|
+
'SHIP',
|
|
796
|
+
'https://shiphost2.com',
|
|
797
|
+
'tm_bar'
|
|
798
|
+
)
|
|
799
|
+
const shipTx2 = new Transaction(
|
|
800
|
+
1,
|
|
801
|
+
[],
|
|
802
|
+
[
|
|
803
|
+
{
|
|
804
|
+
lockingScript: shipScript2,
|
|
805
|
+
satoshis: 1
|
|
806
|
+
}
|
|
807
|
+
],
|
|
808
|
+
0
|
|
809
|
+
)
|
|
602
810
|
|
|
603
811
|
// Resolver returns two hosts
|
|
604
812
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -610,28 +818,32 @@ describe('SHIPCast', () => {
|
|
|
610
818
|
})
|
|
611
819
|
|
|
612
820
|
// First host acknowledges 'tm_foo'
|
|
613
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
821
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
822
|
+
async (host, { beef, topics }) => {
|
|
823
|
+
const steak = {}
|
|
824
|
+
for (const topic of topics) {
|
|
825
|
+
steak[topic] = {
|
|
826
|
+
outputsToAdmit: topic === 'tm_foo' ? [0] : [],
|
|
827
|
+
coinsToRetain: []
|
|
828
|
+
}
|
|
619
829
|
}
|
|
830
|
+
return steak
|
|
620
831
|
}
|
|
621
|
-
|
|
622
|
-
})
|
|
832
|
+
)
|
|
623
833
|
|
|
624
834
|
// Second host does not acknowledge 'tm_bar'
|
|
625
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
835
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
836
|
+
async (host, { beef, topics }) => {
|
|
837
|
+
const steak = {}
|
|
838
|
+
for (const topic of topics) {
|
|
839
|
+
steak[topic] = {
|
|
840
|
+
outputsToAdmit: [],
|
|
841
|
+
coinsToRetain: []
|
|
842
|
+
}
|
|
631
843
|
}
|
|
844
|
+
return steak
|
|
632
845
|
}
|
|
633
|
-
|
|
634
|
-
})
|
|
846
|
+
)
|
|
635
847
|
|
|
636
848
|
const b = new SHIPCast(['tm_foo', 'tm_bar'], {
|
|
637
849
|
facilitator: mockFacilitator,
|
|
@@ -654,22 +866,44 @@ describe('SHIPCast', () => {
|
|
|
654
866
|
|
|
655
867
|
it('should succeed when interested hosts only remove coins in a transaction broadcast', async () => {
|
|
656
868
|
const shipHostKey1 = new PrivateKey(42)
|
|
657
|
-
const shipWallet1 = new
|
|
869
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
658
870
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
659
|
-
const shipScript1 = await shipLib1.lock(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
871
|
+
const shipScript1 = await shipLib1.lock(
|
|
872
|
+
'SHIP',
|
|
873
|
+
'https://shiphost1.com',
|
|
874
|
+
'tm_foo'
|
|
875
|
+
)
|
|
876
|
+
const shipTx1 = new Transaction(
|
|
877
|
+
1,
|
|
878
|
+
[],
|
|
879
|
+
[
|
|
880
|
+
{
|
|
881
|
+
lockingScript: shipScript1,
|
|
882
|
+
satoshis: 1
|
|
883
|
+
}
|
|
884
|
+
],
|
|
885
|
+
0
|
|
886
|
+
)
|
|
664
887
|
|
|
665
888
|
const shipHostKey2 = new PrivateKey(43)
|
|
666
|
-
const shipWallet2 = new
|
|
889
|
+
const shipWallet2 = new CompletedProtoWallet(shipHostKey2)
|
|
667
890
|
const shipLib2 = new OverlayAdminTokenTemplate(shipWallet2)
|
|
668
|
-
const shipScript2 = await shipLib2.lock(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
891
|
+
const shipScript2 = await shipLib2.lock(
|
|
892
|
+
'SHIP',
|
|
893
|
+
'https://shiphost2.com',
|
|
894
|
+
'tm_bar'
|
|
895
|
+
)
|
|
896
|
+
const shipTx2 = new Transaction(
|
|
897
|
+
1,
|
|
898
|
+
[],
|
|
899
|
+
[
|
|
900
|
+
{
|
|
901
|
+
lockingScript: shipScript2,
|
|
902
|
+
satoshis: 1
|
|
903
|
+
}
|
|
904
|
+
],
|
|
905
|
+
0
|
|
906
|
+
)
|
|
673
907
|
|
|
674
908
|
// Resolver returns two hosts
|
|
675
909
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -681,30 +915,34 @@ describe('SHIPCast', () => {
|
|
|
681
915
|
})
|
|
682
916
|
|
|
683
917
|
// First host acknowledges 'tm_foo' with coinsRemoved
|
|
684
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
918
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
919
|
+
async (host, { beef, topics }) => {
|
|
920
|
+
const steak = {}
|
|
921
|
+
for (const topic of topics) {
|
|
922
|
+
steak[topic] = {
|
|
923
|
+
outputsToAdmit: [],
|
|
924
|
+
coinsToRetain: [],
|
|
925
|
+
coinsRemoved: topic === 'tm_foo' ? [0] : []
|
|
926
|
+
}
|
|
691
927
|
}
|
|
928
|
+
return steak
|
|
692
929
|
}
|
|
693
|
-
|
|
694
|
-
})
|
|
930
|
+
)
|
|
695
931
|
|
|
696
932
|
// Second host does not acknowledge 'tm_bar'
|
|
697
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
933
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
934
|
+
async (host, { beef, topics }) => {
|
|
935
|
+
const steak = {}
|
|
936
|
+
for (const topic of topics) {
|
|
937
|
+
steak[topic] = {
|
|
938
|
+
outputsToAdmit: [],
|
|
939
|
+
coinsToRetain: [],
|
|
940
|
+
coinsRemoved: []
|
|
941
|
+
}
|
|
704
942
|
}
|
|
943
|
+
return steak
|
|
705
944
|
}
|
|
706
|
-
|
|
707
|
-
})
|
|
945
|
+
)
|
|
708
946
|
|
|
709
947
|
const b = new SHIPCast(['tm_foo', 'tm_bar'], {
|
|
710
948
|
facilitator: mockFacilitator,
|
|
@@ -726,23 +964,37 @@ describe('SHIPCast', () => {
|
|
|
726
964
|
})
|
|
727
965
|
|
|
728
966
|
// Verify the resolver was queried correctly
|
|
729
|
-
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
967
|
+
expect(mockResolver.query).toHaveBeenCalledWith(
|
|
968
|
+
{
|
|
969
|
+
service: 'ls_ship',
|
|
970
|
+
query: {
|
|
971
|
+
topics: ['tm_foo', 'tm_bar']
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
1000
|
|
975
|
+
)
|
|
735
976
|
})
|
|
736
977
|
|
|
737
978
|
it('should fail when specific hosts do not acknowledge required topics', async () => {
|
|
738
979
|
const shipHostKey1 = new PrivateKey(42)
|
|
739
|
-
const shipWallet1 = new
|
|
980
|
+
const shipWallet1 = new CompletedProtoWallet(shipHostKey1)
|
|
740
981
|
const shipLib1 = new OverlayAdminTokenTemplate(shipWallet1)
|
|
741
|
-
const shipScript1 = await shipLib1.lock(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
982
|
+
const shipScript1 = await shipLib1.lock(
|
|
983
|
+
'SHIP',
|
|
984
|
+
'https://shiphost1.com',
|
|
985
|
+
'tm_foo'
|
|
986
|
+
)
|
|
987
|
+
const shipTx1 = new Transaction(
|
|
988
|
+
1,
|
|
989
|
+
[],
|
|
990
|
+
[
|
|
991
|
+
{
|
|
992
|
+
lockingScript: shipScript1,
|
|
993
|
+
satoshis: 1
|
|
994
|
+
}
|
|
995
|
+
],
|
|
996
|
+
0
|
|
997
|
+
)
|
|
746
998
|
|
|
747
999
|
// Resolver returns one host
|
|
748
1000
|
mockResolver.query.mockReturnValueOnce({
|
|
@@ -751,16 +1003,18 @@ describe('SHIPCast', () => {
|
|
|
751
1003
|
})
|
|
752
1004
|
|
|
753
1005
|
// Host does not acknowledge 'tm_foo'
|
|
754
|
-
mockFacilitator.send.mockImplementationOnce(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
1006
|
+
mockFacilitator.send.mockImplementationOnce(
|
|
1007
|
+
async (host, { beef, topics }) => {
|
|
1008
|
+
const steak = {}
|
|
1009
|
+
for (const topic of topics) {
|
|
1010
|
+
steak[topic] = {
|
|
1011
|
+
outputsToAdmit: [],
|
|
1012
|
+
coinsToRetain: []
|
|
1013
|
+
}
|
|
760
1014
|
}
|
|
1015
|
+
return steak
|
|
761
1016
|
}
|
|
762
|
-
|
|
763
|
-
})
|
|
1017
|
+
)
|
|
764
1018
|
|
|
765
1019
|
const b = new SHIPCast(['tm_foo'], {
|
|
766
1020
|
facilitator: mockFacilitator,
|
|
@@ -784,21 +1038,34 @@ describe('SHIPCast', () => {
|
|
|
784
1038
|
|
|
785
1039
|
it('should handle invalid acknowledgments from hosts gracefully', async () => {
|
|
786
1040
|
const shipHostKey = new PrivateKey(42)
|
|
787
|
-
const shipWallet = new
|
|
1041
|
+
const shipWallet = new CompletedProtoWallet(shipHostKey)
|
|
788
1042
|
const shipLib = new OverlayAdminTokenTemplate(shipWallet)
|
|
789
|
-
const shipScript = await shipLib.lock(
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
1043
|
+
const shipScript = await shipLib.lock(
|
|
1044
|
+
'SHIP',
|
|
1045
|
+
'https://shiphost.com',
|
|
1046
|
+
'tm_foo'
|
|
1047
|
+
)
|
|
1048
|
+
const shipTx = new Transaction(
|
|
1049
|
+
1,
|
|
1050
|
+
[],
|
|
1051
|
+
[
|
|
1052
|
+
{
|
|
1053
|
+
lockingScript: shipScript,
|
|
1054
|
+
satoshis: 1
|
|
1055
|
+
}
|
|
1056
|
+
],
|
|
1057
|
+
0
|
|
1058
|
+
)
|
|
794
1059
|
|
|
795
1060
|
// Resolver returns one host
|
|
796
1061
|
mockResolver.query.mockReturnValueOnce({
|
|
797
1062
|
type: 'output-list',
|
|
798
|
-
outputs: [
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
1063
|
+
outputs: [
|
|
1064
|
+
{
|
|
1065
|
+
beef: shipTx.toBEEF(),
|
|
1066
|
+
outputIndex: 0
|
|
1067
|
+
}
|
|
1068
|
+
]
|
|
802
1069
|
})
|
|
803
1070
|
|
|
804
1071
|
// Host returns invalid acknowledgment
|
|
@@ -833,7 +1100,11 @@ describe('SHIPCast', () => {
|
|
|
833
1100
|
'https://host1.com': new Set(['tm_foo', 'tm_bar']),
|
|
834
1101
|
'https://host2.com': new Set(['tm_foo', 'tm_bar'])
|
|
835
1102
|
}
|
|
836
|
-
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1103
|
+
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1104
|
+
hostAcknowledgments,
|
|
1105
|
+
['tm_foo', 'tm_bar'],
|
|
1106
|
+
'all'
|
|
1107
|
+
)
|
|
837
1108
|
expect(result).toBe(true)
|
|
838
1109
|
})
|
|
839
1110
|
|
|
@@ -842,7 +1113,11 @@ describe('SHIPCast', () => {
|
|
|
842
1113
|
'https://host1.com': new Set(['tm_foo']),
|
|
843
1114
|
'https://host2.com': new Set(['tm_foo', 'tm_bar'])
|
|
844
1115
|
}
|
|
845
|
-
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1116
|
+
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1117
|
+
hostAcknowledgments,
|
|
1118
|
+
['tm_foo', 'tm_bar'],
|
|
1119
|
+
'all'
|
|
1120
|
+
)
|
|
846
1121
|
expect(result).toBe(false)
|
|
847
1122
|
})
|
|
848
1123
|
|
|
@@ -851,7 +1126,11 @@ describe('SHIPCast', () => {
|
|
|
851
1126
|
'https://host1.com': new Set(['tm_foo']),
|
|
852
1127
|
'https://host2.com': new Set(['tm_bar'])
|
|
853
1128
|
}
|
|
854
|
-
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1129
|
+
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1130
|
+
hostAcknowledgments,
|
|
1131
|
+
['tm_foo', 'tm_bar'],
|
|
1132
|
+
'any'
|
|
1133
|
+
)
|
|
855
1134
|
expect(result).toBe(true)
|
|
856
1135
|
})
|
|
857
1136
|
|
|
@@ -860,7 +1139,11 @@ describe('SHIPCast', () => {
|
|
|
860
1139
|
'https://host1.com': new Set(),
|
|
861
1140
|
'https://host2.com': new Set(['tm_bar'])
|
|
862
1141
|
}
|
|
863
|
-
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1142
|
+
const result = (shipCast as any).checkAcknowledgmentFromAllHosts(
|
|
1143
|
+
hostAcknowledgments,
|
|
1144
|
+
['tm_foo', 'tm_bar'],
|
|
1145
|
+
'any'
|
|
1146
|
+
)
|
|
864
1147
|
expect(result).toBe(false)
|
|
865
1148
|
})
|
|
866
1149
|
})
|
|
@@ -871,7 +1154,11 @@ describe('SHIPCast', () => {
|
|
|
871
1154
|
'https://host1.com': new Set(['tm_foo', 'tm_bar']),
|
|
872
1155
|
'https://host2.com': new Set(['tm_foo'])
|
|
873
1156
|
}
|
|
874
|
-
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1157
|
+
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1158
|
+
hostAcknowledgments,
|
|
1159
|
+
['tm_foo', 'tm_bar'],
|
|
1160
|
+
'all'
|
|
1161
|
+
)
|
|
875
1162
|
expect(result).toBe(true)
|
|
876
1163
|
})
|
|
877
1164
|
|
|
@@ -880,7 +1167,11 @@ describe('SHIPCast', () => {
|
|
|
880
1167
|
'https://host1.com': new Set(['tm_foo']),
|
|
881
1168
|
'https://host2.com': new Set(['tm_bar'])
|
|
882
1169
|
}
|
|
883
|
-
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1170
|
+
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1171
|
+
hostAcknowledgments,
|
|
1172
|
+
['tm_foo', 'tm_bar'],
|
|
1173
|
+
'all'
|
|
1174
|
+
)
|
|
884
1175
|
expect(result).toBe(false)
|
|
885
1176
|
})
|
|
886
1177
|
|
|
@@ -889,7 +1180,11 @@ describe('SHIPCast', () => {
|
|
|
889
1180
|
'https://host1.com': new Set(['tm_foo']),
|
|
890
1181
|
'https://host2.com': new Set()
|
|
891
1182
|
}
|
|
892
|
-
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1183
|
+
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1184
|
+
hostAcknowledgments,
|
|
1185
|
+
['tm_foo', 'tm_bar'],
|
|
1186
|
+
'any'
|
|
1187
|
+
)
|
|
893
1188
|
expect(result).toBe(true)
|
|
894
1189
|
})
|
|
895
1190
|
|
|
@@ -898,7 +1193,11 @@ describe('SHIPCast', () => {
|
|
|
898
1193
|
'https://host1.com': new Set(),
|
|
899
1194
|
'https://host2.com': new Set()
|
|
900
1195
|
}
|
|
901
|
-
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1196
|
+
const result = (shipCast as any).checkAcknowledgmentFromAnyHost(
|
|
1197
|
+
hostAcknowledgments,
|
|
1198
|
+
['tm_foo', 'tm_bar'],
|
|
1199
|
+
'any'
|
|
1200
|
+
)
|
|
902
1201
|
expect(result).toBe(false)
|
|
903
1202
|
})
|
|
904
1203
|
})
|
|
@@ -912,7 +1211,10 @@ describe('SHIPCast', () => {
|
|
|
912
1211
|
const requirements = {
|
|
913
1212
|
'https://host1.com': ['tm_foo', 'tm_bar']
|
|
914
1213
|
}
|
|
915
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1214
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1215
|
+
hostAcknowledgments,
|
|
1216
|
+
requirements
|
|
1217
|
+
)
|
|
916
1218
|
expect(result).toBe(true)
|
|
917
1219
|
})
|
|
918
1220
|
|
|
@@ -924,7 +1226,10 @@ describe('SHIPCast', () => {
|
|
|
924
1226
|
const requirements = {
|
|
925
1227
|
'https://host1.com': ['tm_foo', 'tm_bar']
|
|
926
1228
|
}
|
|
927
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1229
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1230
|
+
hostAcknowledgments,
|
|
1231
|
+
requirements
|
|
1232
|
+
)
|
|
928
1233
|
expect(result).toBe(false)
|
|
929
1234
|
})
|
|
930
1235
|
|
|
@@ -936,7 +1241,10 @@ describe('SHIPCast', () => {
|
|
|
936
1241
|
const requirements = {
|
|
937
1242
|
'https://host1.com': 'any'
|
|
938
1243
|
}
|
|
939
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1244
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1245
|
+
hostAcknowledgments,
|
|
1246
|
+
requirements
|
|
1247
|
+
)
|
|
940
1248
|
expect(result).toBe(true)
|
|
941
1249
|
})
|
|
942
1250
|
|
|
@@ -948,7 +1256,10 @@ describe('SHIPCast', () => {
|
|
|
948
1256
|
const requirements = {
|
|
949
1257
|
'https://host1.com': 'any'
|
|
950
1258
|
}
|
|
951
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1259
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1260
|
+
hostAcknowledgments,
|
|
1261
|
+
requirements
|
|
1262
|
+
)
|
|
952
1263
|
expect(result).toBe(false)
|
|
953
1264
|
})
|
|
954
1265
|
|
|
@@ -963,7 +1274,10 @@ describe('SHIPCast', () => {
|
|
|
963
1274
|
'https://host2.com': 'any',
|
|
964
1275
|
'https://host3.com': 'all'
|
|
965
1276
|
}
|
|
966
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1277
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1278
|
+
hostAcknowledgments,
|
|
1279
|
+
requirements
|
|
1280
|
+
)
|
|
967
1281
|
expect(result).toBe(true)
|
|
968
1282
|
})
|
|
969
1283
|
|
|
@@ -978,7 +1292,10 @@ describe('SHIPCast', () => {
|
|
|
978
1292
|
'https://host2.com': 'any',
|
|
979
1293
|
'https://host3.com': ['tm_foo', 'tm_bar']
|
|
980
1294
|
}
|
|
981
|
-
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1295
|
+
const result = (shipCast as any).checkAcknowledgmentFromSpecificHosts(
|
|
1296
|
+
hostAcknowledgments,
|
|
1297
|
+
requirements
|
|
1298
|
+
)
|
|
982
1299
|
expect(result).toBe(false)
|
|
983
1300
|
})
|
|
984
1301
|
})
|