v1.4.0
Some checks failed
CI / build (push) Has been cancelled

This commit is contained in:
ppe
2023-04-14 15:35:09 +02:00
parent cc47e6361f
commit a9463816da
5 changed files with 39 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "warp-contracts",
"version": "1.3.5-beta.0",
"version": "1.4.0",
"description": "An implementation of the SmartWeave smart contract protocol.",
"types": "./lib/types/index.d.ts",
"main": "./lib/cjs/index.js",

View File

@@ -5,7 +5,7 @@ import Arweave from 'arweave';
import { JWKInterface } from 'arweave/node/lib/wallet';
import path from 'path';
import { mineBlock } from '../_helpers';
import { PstContract, PstState } from "../../../contract/PstContract";
import { PstContract, PstState } from '../../../contract/PstContract';
import { Warp } from '../../../core/Warp';
import { DEFAULT_LEVEL_DB_LOCATION, WarpFactory } from '../../../core/WarpFactory';
import { LoggerFactory } from '../../../logging/LoggerFactory';
@@ -189,24 +189,36 @@ describe('Testing the PST kv storage range access', () => {
expect((await pst.currentBalance(aliceWalletAddress)).balance).toEqual(200_000);
expect((await pst.currentBalance(walletAddress)).balance).toEqual(555669 - 655 - 200_000);
expect((await pst.getStorageValues(['check.' + walletAddress + '.' + aliceWalletAddress]))
.cachedValue.get('check.' + walletAddress + '.' + aliceWalletAddress))
.toBeNull();
expect(
(await pst.getStorageValues(['check.' + walletAddress + '.' + aliceWalletAddress])).cachedValue.get(
'check.' + walletAddress + '.' + aliceWalletAddress
)
).toBeNull();
});
it('should withdraw last check', async () => {
expect((await pst.viewState<unknown, ChecksWrittenResult>({ function: 'checksActive' })).result.total)
.toEqual(207_500);
expect((await pst.viewState<unknown, ChecksWrittenResult>({ function: 'checksActive' })).result.total).toEqual(
207_500
);
await pst.writeInteraction({ function: 'withdrawLastCheck', target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M' });
await pst.writeInteraction({ function: 'withdrawLastCheck', target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M' });
await pst.writeInteraction({ function: 'withdrawLastCheck', target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M' });
await pst.writeInteraction({
function: 'withdrawLastCheck',
target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M'
});
await pst.writeInteraction({
function: 'withdrawLastCheck',
target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M'
});
await pst.writeInteraction({
function: 'withdrawLastCheck',
target: 'uhE-QeYS8i4pmUtnxQyHD7dzXFNaJ9oMK-IM-QPNY6M'
});
await mineBlock(warp);
expect((await pst.viewState<unknown, ChecksWrittenResult>({ function: 'checksActive' })).result.total)
.toEqual(200_000);
expect((await pst.viewState<unknown, ChecksWrittenResult>({ function: 'checksActive' })).result.total).toEqual(
200_000
);
});
it('should not be able to write check', async () => {

View File

@@ -114,7 +114,7 @@ describe('Arweave Gateway interaction loader', () => {
const arweave = Arweave.init({ host: 'arweave.net', port: 443, protocol: 'https' });
const arLoader = new ArweaveGatewayBundledInteractionLoader(arweave, 'mainnet');
const wrLoader = new WarpGatewayContractDefinitionLoader(arweave, contractsCache, sourceCache, 'mainnet')
const wrLoader = new WarpGatewayContractDefinitionLoader(arweave, contractsCache, sourceCache, 'mainnet');
const withArLoader = WarpFactory.custom(arweave, { inMemory: true, dbLocation: '' }, 'mainnet')
.setInteractionsLoader(arLoader)
.setDefinitionLoader(wrLoader)
@@ -122,7 +122,6 @@ describe('Arweave Gateway interaction loader', () => {
arLoader.warp = withArLoader;
wrLoader.warp = withArLoader;
const arResult = await withArLoader
.contract(EXAMPLE_CONTRACT_TX_ID)
.setEvaluationOptions({ allowBigInt: true })

View File

@@ -1,9 +1,12 @@
import Arweave from 'arweave';
import { LexicographicalInteractionsSorter } from '../../core/modules/impl/LexicographicalInteractionsSorter';
import {ConfirmationStatus, WarpGatewayInteractionsLoader} from '../../core/modules/impl/WarpGatewayInteractionsLoader';
import {
ConfirmationStatus,
WarpGatewayInteractionsLoader
} from '../../core/modules/impl/WarpGatewayInteractionsLoader';
import { GQLNodeInterface } from '../../legacy/gqlResult';
import { LoggerFactory } from '../../logging/LoggerFactory';
import {WarpFactory} from "../../core/WarpFactory";
import { WarpFactory } from '../../core/WarpFactory';
const responseData = {
paging: {
@@ -122,12 +125,12 @@ describe('WarpGatewayInteractionsLoader -> load', () => {
expect(fetchMock).toHaveBeenCalledTimes(5);*/
});
it('should be called with confirmationStatus set to "confirmed"', async () => {
const loader = getLoader({confirmed: true});
const loader = getLoader({ confirmed: true });
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&fromSdk=true&confirmationStatus=confirmed`);
});
it('should be called with confirmationStatus set to "not_corrupted"', async () => {
const loader = getLoader({notCorrupted: true});
const loader = getLoader({ notCorrupted: true });
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&fromSdk=true&confirmationStatus=not_corrupted`);
});
@@ -148,7 +151,11 @@ describe('WarpGatewayInteractionsLoader -> load', () => {
try {
await loader.load(contractId, fromBlockHeight, toBlockHeight);
} catch (e) {
expect(e).toEqual(new Error('Error while communicating with gateway: {"status":500,"ok":false,"body":{"message":"request fails"}}'));
expect(e).toEqual(
new Error(
'Error while communicating with gateway: {"status":500,"ok":false,"body":{"message":"request fails"}}'
)
);
}
});
});

View File

@@ -1,6 +1,6 @@
/* eslint-disable */
import copy from 'fast-copy';
import {Buffer} from 'warp-isomorphic';
import { Buffer } from 'warp-isomorphic';
export const sleep = (ms: number): Promise<void> => {
return new Promise((resolve) => setTimeout(resolve, ms));
@@ -101,5 +101,4 @@ export async function getJsonResponse<T>(response: Promise<Response>): Promise<T
}
const result = await r.json();
return result as T;
}