All files / fixtures fixtures.ts

92.3% Statements 12/13
100% Branches 1/1
90% Functions 9/10
92.3% Lines 12/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66    4x     1x                     4x       4x           3x 3x           23x 23x     3x       18x       18x               3x                        
import { rpc, xdr } from "@stellar/stellar-sdk";
 
export const contractAddressTxReponse = {
  returnValue: {
    address: (): xdr.ScAddress => {
      return xdr.ScAddress.scAddressTypeContract(
        Buffer.from(
          "227ca7b59a114b96adc361d1d5ce76cb1e2ffe6fa797296749638fded54f9550",
          "hex"
        )
      );
    },
  },
  status: rpc.Api.GetTransactionStatus.SUCCESS,
};
 
export const pollTxReponseSuccess = {
  status: rpc.Api.GetTransactionStatus.SUCCESS,
};
 
export const pollTxReponseNotFound = {
  status: rpc.Api.GetTransactionStatus.NOT_FOUND,
};
 
export class FakeStellarRpc {
  assembleTransaction(raw: any, simulation: any) {
    return {
      build: () => ({ sign: () => { } }),
    };
  }
}
 
export class FakeServer {
  public serverURL = "aServerUrl";
  constructor(private readonly _pollTransactionReponse: any = {}) { }
 
  getNetwork() {
    return Promise.resolve({ passphrase: "aPassphrase" });
  }
 
  sendTransaction(tx: any) {
    return { hash: "aTxHash" };
  }
 
  pollTransaction(hash: string) {
    return this._pollTransactionReponse;
  }
 
  async getLatestLedger(): Promise<any> {
    return { sequence: 1234 }
  }
 
  async simulateTransaction() {
    return {
      transactionData: {},
      minResourceFee: '123',
      result: {},
      stateChanges: [],
      id: '1234',
      latestLedger: 1234,
      events: [],
      _parsed: false
    };
  }
}