2022-11-09 02:57:02 -05:00
|
|
|
"use strict";
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const assert_1 = __importDefault(require("assert"));
|
|
|
|
const index_js_1 = require("../index.js");
|
|
|
|
const create_provider_js_1 = require("./create-provider.js");
|
2022-11-09 06:22:17 -05:00
|
|
|
function stall(duration) {
|
|
|
|
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
|
|
|
}
|
2022-12-30 16:35:04 -05:00
|
|
|
(0, create_provider_js_1.setupProviders)();
|
2022-11-09 02:57:02 -05:00
|
|
|
describe("Sends Transactions", function () {
|
|
|
|
const wallet = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY));
|
|
|
|
const networkName = "goerli";
|
|
|
|
for (const providerName of create_provider_js_1.providerNames) {
|
|
|
|
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
|
|
|
|
if (provider == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
it(`tests sending: ${providerName}`, async function () {
|
2022-12-09 18:24:58 -05:00
|
|
|
this.timeout(180000);
|
2022-11-09 02:57:02 -05:00
|
|
|
const w = wallet.connect(provider);
|
|
|
|
const dustAddr = index_js_1.Wallet.createRandom().address;
|
2022-11-09 06:22:17 -05:00
|
|
|
// Retry if another CI instance used our value
|
|
|
|
let tx = null;
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
try {
|
|
|
|
tx = await w.sendTransaction({
|
|
|
|
to: dustAddr,
|
|
|
|
value: 42,
|
|
|
|
type: 2
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
catch (error) {
|
2022-12-30 11:53:40 -05:00
|
|
|
if ((0, index_js_1.isError)(error, "REPLACEMENT_UNDERPRICED") || (0, index_js_1.isError)(error, "NONCE_EXPIRED")) {
|
2022-11-09 06:22:17 -05:00
|
|
|
await stall(1000);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert_1.default.ok(!!tx, "too many retries");
|
2022-11-09 02:57:02 -05:00
|
|
|
//const receipt =
|
2022-12-09 18:24:58 -05:00
|
|
|
await provider.waitForTransaction(tx.hash, null, 60000); //tx.wait();
|
2022-11-09 02:57:02 -05:00
|
|
|
//console.log(receipt);
|
|
|
|
const balance = await provider.getBalance(dustAddr);
|
|
|
|
assert_1.default.equal(balance, BigInt(42), "target balance after send");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
//# sourceMappingURL=test-providers-send.js.map
|