Skip to content

Commit

Permalink
update spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Apr 11, 2024
1 parent 90baaf9 commit fa1f16a
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions src/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('wallet', () => {
});

describe('transactions', () => {
it('processes transaction with valid address', async () => {
it('processes transaction with valid address and data field', async () => {
const { engine } = createTestSetup();
const getAccounts = async () => testAddresses.slice(0, 2);
const witnessedTxParams: TransactionParams[] = [];
Expand Down Expand Up @@ -90,6 +90,7 @@ describe('wallet', () => {
engine.push(createWalletMiddleware({ getAccounts, processTransaction }));
const txParams = {
from: '0x3d',
data: '0x0',
};

const payload = { method: 'eth_sendTransaction', params: [txParams] };
Expand All @@ -109,6 +110,7 @@ describe('wallet', () => {
engine.push(createWalletMiddleware({ getAccounts, processTransaction }));
const txParams = {
from: testUnkownAddress,
data: '0x0',
};

const payload = { method: 'eth_sendTransaction', params: [txParams] };
Expand All @@ -118,29 +120,6 @@ describe('wallet', () => {
);
});

it('processes transaction with data field but without input field', async () => {
const { engine } = createTestSetup();
const getAccounts = async () => testAddresses.slice(0, 2);
const witnessedTxParams: TransactionParams[] = [];
const processTransaction = async (_txParams: TransactionParams) => {
witnessedTxParams.push(_txParams);
return testTxHash;
};
engine.push(createWalletMiddleware({ getAccounts, processTransaction }));
const txParams = {
from: testAddresses[0],
data: '0x0',
};

const payload = { method: 'eth_sendTransaction', params: [txParams] };
const sendTxResponse = await pify(engine.handle).call(engine, payload);
const sendTxResult = sendTxResponse.result;
expect(sendTxResult).toBeDefined();
expect(sendTxResult).toStrictEqual(testTxHash);
expect(witnessedTxParams).toHaveLength(1);
expect(witnessedTxParams[0]).toStrictEqual(txParams);
});

it('processes transaction with input field but without data field', async () => {
const { engine } = createTestSetup();
const getAccounts = async () => testAddresses.slice(0, 2);
Expand Down

0 comments on commit fa1f16a

Please sign in to comment.