stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
72 lines (71 loc) • 3.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const account_1 = require("../../../stellar-plus/account");
const asset_1 = require("../../../stellar-plus/asset");
const network_1 = require("../../../stellar-plus/network");
const stellar_test_ledger_1 = require("../../../stellar-plus/test/stellar-test-ledger");
const regex_1 = require("../../../stellar-plus/utils/regex");
const utils_1 = require("../../../tests/utils");
describe('Classic Asset Wrapping Use Case: ', () => {
const logLevel = 'TRACE';
const stellarTestLedger = new stellar_test_ledger_1.StellarTestLedger({
logLevel,
network: stellar_test_ledger_1.TestLedgerNetwork.LOCAL,
containerImageVersion: stellar_test_ledger_1.SupportedImageVersions.LASTEST,
});
let networkConfig;
beforeAll(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const container = yield stellarTestLedger.start();
expect(container).toBeDefined();
networkConfig = (0, network_1.CustomNet)(yield stellarTestLedger.getNetworkConfiguration());
expect(networkConfig.horizonUrl).toBeDefined();
expect(networkConfig.networkPassphrase).toBeDefined();
expect(networkConfig.rpcUrl).toBeDefined();
expect(networkConfig.friendbotUrl).toBeDefined();
}));
afterAll(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield stellarTestLedger.stop();
yield stellarTestLedger.destroy();
}));
describe('Given an issuer with lumens', () => {
let issuer;
beforeAll(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
issuer = new account_1.DefaultAccountHandler({ networkConfig });
yield issuer.initializeWithFriendbot();
expect(issuer).toBeDefined();
}));
describe('A Classic Asset Handler initialized with the issuer account handler', () => {
let sac;
beforeAll(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
sac = new asset_1.SACHandler({
code: 'SPLUS',
issuerAccount: issuer,
networkConfig,
});
expect(sac).toBeDefined();
}));
it('should be wrapped in an SAC', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
yield expect(sac.wrapAndDeploy((0, utils_1.simpleTxInvocation)(issuer))).toResolve();
expect(sac.sorobanTokenHandler.getContractId()).toMatch(regex_1.contractIdRegex);
}));
it('should handle when asset is already wrapped in an SAC', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const sacInstance = new asset_1.SACHandler({
code: 'SPLUS2',
issuerAccount: issuer,
networkConfig,
});
const newSacInstance = new asset_1.SACHandler({
code: 'SPLUS2',
issuerAccount: issuer,
networkConfig,
});
yield sacInstance.wrapAndDeploy((0, utils_1.simpleTxInvocation)(issuer));
yield expect(newSacInstance.wrapAndDeploy((0, utils_1.simpleTxInvocation)(issuer))).toResolve();
expect(newSacInstance.sorobanTokenHandler.getContractId()).toMatch(regex_1.contractIdRegex);
expect(sacInstance.sorobanTokenHandler.getContractId()).toBe(newSacInstance.sorobanTokenHandler.getContractId());
}));
});
});
});