Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/bitgo/test/v2/unit/coins/utxo/recovery/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { Bsv } from '@bitgo/sdk-coin-bsv';

type Unspent<TNumber extends number | bigint = number> = bitgo.Unspent<TNumber>;
export class MockRecoveryProvider implements RecoveryProvider {
public unspents: Unspent<bigint>[];
private prevTxCache: Record<string, string> = {};
constructor(public unspents: Unspent<bigint>[]) {
constructor(unspents: Unspent<bigint>[]) {
this.unspents = unspents;
this.unspents.forEach((u) => {
if (utxolib.bitgo.isUnspentWithPrevTx(u)) {
const { txid } = bitgo.parseOutputId(u.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe('non-TSS Staking Wallet', function () {
.reply(200, transaction);

const prebuildTransaction = sandbox.stub(Wallet.prototype, 'prebuildTransaction');
const descriptor = sandbox.stub(StakingWallet.prototype, <any>'getDescriptorWallet');
const descriptor = sandbox.stub(StakingWallet.prototype, 'getDescriptorWallet' as any);
await btcStakingWallet.build(transaction);
prebuildTransaction.calledOnceWithExactly(transaction.buildParams).should.be.true;
descriptor.notCalled.should.be.true;
Expand Down
9 changes: 8 additions & 1 deletion modules/blockapis/test/UtxoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ type MethodArguments = unknown[];
* A test case for a UtxoApi method.
*/
class TestCase<T> {
public coinName: string;
public methodName: keyof UtxoApi;
public args: unknown[];
/**
* @param coinName - coin to test
* @param methodName - method to test
* @param args - method arguments
*/
constructor(public coinName: string, public methodName: keyof UtxoApi, public args: unknown[]) {}
constructor(coinName: string, methodName: keyof UtxoApi, args: unknown[]) {
this.coinName = coinName;
this.methodName = methodName;
this.args = args;
}

/**
* Call the method on the given API.
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-eos/test/unit/eos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('EOS:', function () {

// mock responses to the block chain
const sandBox = sinon.createSandbox();
const callBack = sandBox.stub(Eos.prototype, <any>'getDataFromNode');
const callBack = sandBox.stub(Eos.prototype, 'getDataFromNode' as any);
callBack
.withArgs({
endpoint: '/v1/chain/get_account',
Expand Down Expand Up @@ -380,7 +380,7 @@ describe('EOS:', function () {
beforeEach(async () => {
// mock responses to the block chain
sandBox = sinon.createSandbox();
const callBack = sandBox.stub(Eos.prototype, <any>'getDataFromNode');
const callBack = sandBox.stub(Eos.prototype, 'getDataFromNode' as any);
callBack
.withArgs({
endpoint: '/v1/chain/get_info',
Expand Down
10 changes: 8 additions & 2 deletions modules/sdk-coin-sui/test/local_fullnode/RpcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ function unwrapResult<A>(method: string, v: { result: A } | { error: { code: num
}

export class RpcError extends Error {
constructor(public rpcError: { code: number; message: string }) {
public rpcError: { code: number; message: string };

constructor(rpcError: { code: number; message: string }) {
super(`RPC error: ${rpcError.message} (code=${rpcError.code})`);
this.rpcError = rpcError;
}

static isRpcErrorWithCode(e: Error, code: number): boolean {
Expand All @@ -44,10 +47,13 @@ export type Coin = {

/** Wrapper around https://docs.sui.io/sui-jsonrpc */
export class RpcClient {
public url: string;
// Running counter, increments every request
id = 0;

constructor(public url: string) {}
constructor(url: string) {
this.url = url;
}

static async createCheckedConnection(url: string): Promise<RpcClient> {
const rpcClient = new RpcClient(url);
Expand Down
5 changes: 4 additions & 1 deletion modules/sdk-coin-sui/test/local_fullnode/faucet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import axios from 'axios';

export class Faucet {
constructor(public url: string) {}
public url: string;
constructor(url: string) {
this.url = url;
}

async getCoins(address: string, amount: number): Promise<void> {
await axios.post(this.url + '/gas', { FixedAmountRequest: { recipient: address } });
Expand Down
29 changes: 22 additions & 7 deletions modules/unspents/test/signedTx/txGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,29 @@ function signInput(
}

class TxCombo {
public walletKeys: BIP32Interface[];
public inputTypes: string[];
public outputTypes: TestUnspentType[];
public expectedDims: Readonly<Dimensions>;
public signKeys?: BIP32Interface[];
public inputValue: number;
public unspents: IUnspent[];
public inputTx: any;

constructor(
public walletKeys: BIP32Interface[],
public inputTypes: string[],
public outputTypes: TestUnspentType[],
public expectedDims: Readonly<Dimensions> = Dimensions.ZERO,
public signKeys?: BIP32Interface[],
public inputValue: number = 10
walletKeys: BIP32Interface[],
inputTypes: string[],
outputTypes: TestUnspentType[],
expectedDims: Readonly<Dimensions> = Dimensions.ZERO,
signKeys?: BIP32Interface[],
inputValue = 10
) {
this.walletKeys = walletKeys;
this.inputTypes = inputTypes;
this.outputTypes = outputTypes;
this.expectedDims = expectedDims;
this.signKeys = signKeys;
this.inputValue = inputValue;
this.unspents = inputTypes.map((inputType) =>
createUnspent(
walletKeys.map((key) => key.publicKey),
Expand Down Expand Up @@ -180,9 +192,12 @@ const runCombinations = (
};

class Histogram {
public map: Map<number, number>;
public total = 0;

constructor(public map: Map<number, number> = new Map()) {}
constructor(map: Map<number, number> = new Map()) {
this.map = map;
}

public add(size: number): void {
this.map.set(size, (this.map.get(size) || 0) + 1);
Expand Down
5 changes: 4 additions & 1 deletion modules/unspents/test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export const UnspentTypePubKeyHash: {
export type TestUnspentType = string | UnspentTypeOpReturn;

export class UnspentTypeOpReturn {
constructor(public size: number) {}
public size: number;
constructor(size: number) {
this.size = size;
}

public toString(): string {
return `opReturn(${this.size})`;
Expand Down