it('should return true if peers() returns a matching bytes32', async () => {
                    await fc.assert(
                        fc.asyncProperty(
                            omniContractArbitrary,
                            aptosEndpointArbitrary,
                            aptosAddressArbitrary,
                            async (omniContract, peerEid, peer) => {
                                omniContract.contract.peers.mockResolvedValue(makeBytes32(peer))

                                const sdk = new OApp(omniContract)

                                await expect(sdk.hasPeer(peerEid, peer)).resolves.toBe(true)
                                await expect(sdk.hasPeer(peerEid, makeBytes32(peer))).resolves.toBe(true)
                            }
                        )
                    )
                })

Summary: The method `hasPeer` should return true when `peers()` returns a bytes32 value that matches the provided peer.


unknown

it('queries with `splits: none` returns only parents', async () => {
    await fc.assert(
      fc.asyncProperty(
        arbs.makeTransactionArray({
          splitFreq: 2,
          minLength: 2,
          maxLength: 8
        }),
        async arr => {
          await insertTransactions(arr);

          let { data } = await runQuery(
            query('transactions')
              .filter({ amount: { $lt: 0 } })
              .select('*')
              .options({ splits: 'none' })
              .serialize()
          );

          expect(data.filter(t => t.is_child).length).toBe(0);
        }
      ),
      { numRuns: 50 }
    );
  })

Summary: Queries with the option `splits: none` should return only transactions that are not children, excluding any split transactions.


it('should encode data for a setPeer call', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        evmEndpointArbitrary,
                        evmAddressArbitrary,
                        async (omniContract, peerEid, peerAddress) => {
                            const sdk = new OApp(omniContract)
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData

                            ;(encodeFunctionData as jest.Mock).mockClear()

                            await sdk.setPeer(peerEid, peerAddress)

                            expect(encodeFunctionData).toHaveBeenCalledTimes(1)
                            expect(encodeFunctionData).toHaveBeenCalledWith('setPeer', [
                                peerEid,
                                makeBytes32(peerAddress),
                            ])
                        }
                    )
                )
            })

Summary: `setPeer` call correctly encodes data using `encodeFunctionData` with `peerEid` and a bytes32 formatted `peerAddress`.


it('should return an OmniTransaction', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        evmEndpointArbitrary,
                        evmAddressArbitrary,
                        fc.string(),
                        async (omniContract, peerEid, peerAddress, data) => {
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData as jest.Mock
                            encodeFunctionData.mockReturnValue(data)

                            const sdk = new OApp(omniContract)
                            const transaction = await sdk.setPeer(peerEid, peerAddress)

                            expect(transaction).toEqual({
                                data,
                                description: `Setting peer for eid ${peerEid} (${formatEid(peerEid)}) to address ${makeBytes32(peerAddress)}`,
                                point: {
                                    eid: omniContract.eid,
                                    address: omniContract.contract.address,
                                },
                            })
                        }
                    )
                )
            })

Summary: Returns an `OmniTransaction` object with correctly formatted data, description, and point properties after calling `setPeer` on an `OApp` instance with given inputs.


it('should encode data for a setPeer call', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        solanaEndpointArbitrary,
                        solanaAddressArbitrary,
                        async (omniContract, peerEid, peerAddress) => {
                            const sdk = new OApp(omniContract)
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData

                            ;(encodeFunctionData as jest.Mock).mockClear()

                            await sdk.setPeer(peerEid, peerAddress)

                            expect(encodeFunctionData).toHaveBeenCalledTimes(1)
                            expect(encodeFunctionData).toHaveBeenCalledWith('setPeer', [
                                peerEid,
                                makeBytes32(normalizePeer(peerAddress, peerEid)),
                            ])
                        }
                    )
                )
            })

Summary: The test ensures that calling `setPeer` on an `OApp` instance results in exactly one call to `encodeFunctionData` with the appropriate `setPeer` function name and parameters consisting of `peerEid` and a normalized byte representation of `peerAddress` paired with `peerEid`.


it('should return an OmniTransaction', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        solanaEndpointArbitrary,
                        solanaAddressArbitrary,
                        fc.string(),
                        async (omniContract, peerEid, peerAddress, data) => {
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData as jest.Mock
                            encodeFunctionData.mockReturnValue(data)

                            const sdk = new OApp(omniContract)
                            const transaction = await sdk.setPeer(peerEid, peerAddress)

                            expect(transaction).toEqual({
                                data,
                                description: `Setting peer for eid ${peerEid} (${formatEid(peerEid)}) to address ${makeBytes32(normalizePeer(peerAddress, peerEid))}`,
                                point: {
                                    eid: omniContract.eid,
                                    address: omniContract.contract.address,
                                },
                            })
                        }
                    )
                )
            })

Summary: An `OmniTransaction` should be returned with correctly structured data, a description including peer details, and point information after setting a peer.


it('should encode data for a setPeer call', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        aptosEndpointArbitrary,
                        aptosAddressArbitrary,
                        async (omniContract, peerEid, peerAddress) => {
                            const sdk = new OApp(omniContract)
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData

                            ;(encodeFunctionData as jest.Mock).mockClear()

                            await sdk.setPeer(peerEid, peerAddress)

                            expect(encodeFunctionData).toHaveBeenCalledTimes(1)
                            expect(encodeFunctionData).toHaveBeenCalledWith('setPeer', [
                                peerEid,
                                makeBytes32(peerAddress),
                            ])
                        }
                    )
                )
            })

Summary: Verifies that calling `setPeer` on an `OApp` instance invokes the `encodeFunctionData` method exactly once with the correct arguments: the string 'setPeer' and an array containing `peerEid` and a bytes32 representation of `peerAddress`.


it('should return an OmniTransaction', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        omniContractArbitrary,
                        aptosEndpointArbitrary,
                        aptosAddressArbitrary,
                        fc.string(),
                        async (omniContract, peerEid, peerAddress, data) => {
                            const encodeFunctionData = omniContract.contract.interface.encodeFunctionData as jest.Mock
                            encodeFunctionData.mockReturnValue(data)

                            const sdk = new OApp(omniContract)
                            const transaction = await sdk.setPeer(peerEid, peerAddress)

                            expect(transaction).toEqual({
                                data,
                                description: `Setting peer for eid ${peerEid} (${formatEid(peerEid)}) to address ${makeBytes32(peerAddress)}`,
                                point: {
                                    eid: omniContract.eid,
                                    address: omniContract.contract.address,
                                },
                            })
                        }
                    )
                )
            })

Summary: The function `setPeer` in `OApp` should return an `OmniTransaction` with correctly formatted data, description, and point, based on the provided peer ID and address inputs.


it('should reject if the call to endpoint() rejects', async () => {
            await fc.assert(
                fc.asyncProperty(omniContractArbitrary, async (omniContract) => {
                    omniContract.contract.endpoint.mockRejectedValue('No you did not')

                    const sdk = new OApp(omniContract)

                    await expect(sdk.getEndpointSDK()).rejects.toThrow(/Failed to get EndpointV2 address for OApp/)
                })
            )
        })

Summary: `OApp` should reject with an error when `endpoint()` call is mocked to reject, indicating failure to get the EndpointV2 address.


it('should reject if the call to endpoint() resolves with a zeroish address', async () => {
            await fc.assert(
                fc.asyncProperty(
                    omniContractArbitrary,
                    nullishAddressArbitrary,
                    async (omniContract, endpointAddress) => {
                        omniContract.contract.endpoint.mockResolvedValue(endpointAddress)

                        const sdk = new OApp(omniContract)

                        await expect(sdk.getEndpointSDK()).rejects.toThrow(
                            /EndpointV2 cannot be instantiated: EndpointV2 address has been set to a zero value for OApp/
                        )
                    }
                )
            )
        })

Summary: `OApp.getEndpointSDK` should reject with an error if `endpoint()` resolves to an address with a zero-like value.


it('should return the contract symbol', async () => {
            await fc.assert(
                fc.asyncProperty(omniContractArbitrary, fc.string(), async (omniContract, symbol) => {
                    omniContract.contract.symbol.mockResolvedValue(symbol)

                    const sdk = new ERC20(omniContract)

                    await expect(sdk.getSymbol()).resolves.toBe(symbol)

                    expect(omniContract.contract.symbol).toHaveBeenCalledTimes(1)
                })
            )
        })

Summary: The function `getSymbol` should retrieve the correct contract symbol by invoking `omniContract.contract.symbol` once, with the result matching a predefined string.


it('should return the contract decimals', async () => {
            await fc.assert(
                fc.asyncProperty(omniContractArbitrary, fc.integer({ min: 1 }), async (omniContract, decimals) => {
                    omniContract.contract.decimals.mockResolvedValue(decimals)

                    const sdk = new ERC20(omniContract)

                    await expect(sdk.getDecimals()).resolves.toBe(decimals)

                    expect(omniContract.contract.decimals).toHaveBeenCalledTimes(1)
                })
            )
        })

Summary: `ERC20` returns the correct contract decimals by invoking the `decimals` function exactly once on the contract.


it('should return the user balance', async () => {
            await fc.assert(
                fc.asyncProperty(
                    omniContractArbitrary,
                    evmAddressArbitrary,
                    fc.bigInt({ min: BigInt(0) }),
                    async (omniContract, user, balance) => {
                        omniContract.contract.balanceOf.mockResolvedValue(BigNumber.from(balance))

                        const sdk = new ERC20(omniContract)

                        await expect(sdk.getBalanceOf(user)).resolves.toBe(balance)

                        expect(omniContract.contract.balanceOf).toHaveBeenCalledTimes(1)
                        expect(omniContract.contract.balanceOf).toHaveBeenCalledWith(user)
                    }
                )
            )
        })

Summary: The `getBalanceOf` method should return the correct user balance, with the `balanceOf` function being called once with the appropriate user address.


it('should return the user balance', async () => {
            await fc.assert(
                fc.asyncProperty(
                    omniContractArbitrary,
                    evmAddressArbitrary,
                    evmAddressArbitrary,
                    fc.bigInt({ min: BigInt(0) }),
                    async (omniContract, owner, spender, allowance) => {
                        omniContract.contract.allowance.mockResolvedValue(BigNumber.from(allowance))

                        const sdk = new ERC20(omniContract)

                        await expect(sdk.getAllowance(owner, spender)).resolves.toBe(allowance)

                        expect(omniContract.contract.allowance).toHaveBeenCalledTimes(1)
                        expect(omniContract.contract.allowance).toHaveBeenCalledWith(owner, spender)
                    }
                )
            )
        })

Summary: `ERC20.getAllowance` returns the correct allowance for a given owner and spender, ensuring the contract's `allowance` function is called once with the correct parameters.


it('should not attempt to register libraries multiple times', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    pointArbitrary,
                    pointArbitrary,
                    addressArbitrary,
                    async (pointA, pointB, pointC, libraryAddress) => {
                        fc.pre(!arePointsEqual(pointA, pointB))
                        fc.pre(!arePointsEqual(pointB, pointC))
                        fc.pre(!arePointsEqual(pointC, pointA))

                        const config: EndpointV2EdgeConfig = {
                            defaultReceiveLibrary: libraryAddress,
                            defaultSendLibrary: libraryAddress,
                        }

                        const graph: EndpointV2OmniGraph = {
                            contracts: [],
                            connections: [
                                {
                                    vector: { from: pointA, to: pointB },
                                    config,
                                },
                                {
                                    vector: { from: pointA, to: pointC },
                                    config,
                                },
                                {
                                    vector: { from: pointB, to: pointA },
                                    config,
                                },
                                {
                                    vector: { from: pointB, to: pointC },
                                    config,
                                },
                                {
                                    vector: { from: pointC, to: pointA },
                                    config,
                                },
                                {
                                    vector: { from: pointC, to: pointB },
                                    config,
                                },
                            ],
                        }

                        const createSdk = jest.fn((point: OmniPoint) => new MockSDK(point) as unknown as IEndpointV2)
                        const result = await configureEndpointV2RegisterLibraries(graph, createSdk)

                        // The result should not contain any duplicate library registrations
                        expect(result).toEqual([
                            { point: pointA, data: `0xREGISTERLIBRARY ${libraryAddress}` },
                            { point: pointB, data: `0xREGISTERLIBRARY ${libraryAddress}` },
                            { point: pointC, data: `0xREGISTERLIBRARY ${libraryAddress}` },
                        ])
                    }
                )
            )
        })

Summary: The function `configureEndpointV2RegisterLibraries` should register each library once per unique point, ensuring no duplicate registrations in the output.


describe('transaction executors', () => {
  it('queries with `splits: inline` returns only non-parents', async () => {
    await fc.assert(
      fc.asyncProperty(
        arbs.makeTransactionArray({
          splitFreq: 2,
          minLength: 2,
          maxLength: 20
        }),
        async arr => {
          await insertTransactions(arr);

          let { data } = await runQuery(
            query('transactions')
              .filter({ amount: { $lt: 0 } })
              .select('*')
              .options({ splits: 'inline' })
              .serialize()
          );

          expect(data.filter(t => t.is_parent).length).toBe(0);
          expect(data.filter(t => t.tombstone).length).toBe(0);

          let { data: defaultData } = await runQuery(
            query('transactions')
              .filter({ amount: { $lt: 0 } })
              .select('*')
              .serialize()
          );

          // inline should be the default
          expect(defaultData).toEqual(data);
        }
      ),
      { numRuns: 50 }
    );
  });

  it('queries with `splits: none` returns only parents', async () => {
    await fc.assert(
      fc.asyncProperty(
        arbs.makeTransactionArray({
          splitFreq: 2,
          minLength: 2,
          maxLength: 8
        }),
        async arr => {
          await insertTransactions(arr);

          let { data } = await runQuery(
            query('transactions')
              .filter({ amount: { $lt: 0 } })
              .select('*')
              .options({ splits: 'none' })
              .serialize()
          );

          expect(data.filter(t => t.is_child).length).toBe(0);
        }
      ),
      { numRuns: 50 }
    );
  });

  it('aggregate queries work with `splits: grouped`', async () => {
    let payeeIds = ['payee1', 'payee2', 'payee3', 'payee4', 'payee5'];

    await fc.assert(
      fc
        .asyncProperty(
          arbs.makeTransactionArray({ splitFreq: 2, payeeIds, maxLength: 100 }),
          async arr => {
            await insertTransactions(arr, payeeIds);

            let aggQuery = query('transactions')
              .filter({
                $or: [{ amount: { $lt: -5 } }, { amount: { $gt: -2 } }],
                'payee.name': { $gt: '' }
              })
              .options({ splits: 'grouped' })
              .calculate({ $sum: '$amount' });

            let { data } = await runQuery(aggQuery.serialize());

            let sum = arr.reduce((sum, trans) => {
              let amount = trans.amount || 0;
              let matched = (amount < -5 || amount > -2) && trans.payee != null;
              if (!trans.tombstone && !trans.is_parent && matched) {
                return sum + amount;
              }
              return sum;
            }, 0);

            expect(data).toBe(sum);
          }
        )
        .beforeEach(() => {
          setClock(null);
          setSyncingMode('import');
          return db.execQuery(`
            DELETE FROM transactions;
            DELETE FROM payees;
            DELETE FROM payee_mapping;
          `);
        })
    );
  });

  function runTest(makeQuery) {
    let payeeIds = ['payee1', 'payee2', 'payee3', 'payee4', 'payee5'];

    async function check(arr) {
      let orderFields = ['payee.name', 'amount', 'id'];

      // Insert transactions and get a list of all the alive
      // ones to make it easier to check the data later (don't
      // have to always be filtering out dead ones)
      await insertTransactions(arr, payeeIds);
      let allTransactions = aliveTransactions(arr);

      // Query time
      let { query, expectedIds, expectedMatchedIds } = makeQuery(arr);

      // First to a query without order to make sure the default
      // order works
      let { data: defaultOrderData } = await runQuery(query.serialize());
      expectTransactionOrder(defaultOrderData);
      expect(new Set(defaultOrderData.map(t => t.id))).toEqual(expectedIds);

      // Now do the full test, and add a custom order to make
      // sure that doesn't effect anything
      let orderedQuery = query.orderBy(orderFields);
      let { data } = await runQuery(orderedQuery.serialize());
      expect(new Set(data.map(t => t.id))).toEqual(expectedIds);

      // Validate paging and ordering
      await expectPagedData(orderedQuery, arr.length, data);
      expectTransactionOrder(data, orderFields);

      let matchedIds = new Set();

      // Check that all the subtransactions were returned
      for (let trans of data) {
        expect(trans.tombstone).toBe(false);

        if (expectedMatchedIds) {
          if (!trans._unmatched) {
            expect(expectedMatchedIds.has(trans.id)).toBe(true);
            matchedIds.add(trans.id);
          } else {
            expect(expectedMatchedIds.has(trans.id)).not.toBe(true);
          }
        }

        if (trans.is_parent) {
          // Parent transactions should never have a category
          expect(trans.category).toBe(null);

          expect(trans.subtransactions.length).toBe(
            allTransactions.filter(t => t.parent_id === trans.id).length
          );

          // Subtransactions should be ordered as well
          expectTransactionOrder(trans.subtransactions, orderFields);

          trans.subtransactions.forEach(subtrans => {
            expect(subtrans.tombstone).toBe(false);

            if (expectedMatchedIds) {
              if (!subtrans._unmatched) {
                expect(expectedMatchedIds.has(subtrans.id)).toBe(true);
                matchedIds.add(subtrans.id);
              } else {
                expect(expectedMatchedIds.has(subtrans.id)).not.toBe(true);
              }
            }
          });
        }
      }

      if (expectedMatchedIds) {
        // Check that transactions that should be matched are
        // marked as such
        expect(matchedIds).toEqual(expectedMatchedIds);
      }
    }

    return fc.assert(
      fc
        .asyncProperty(
          arbs.makeTransactionArray({
            splitFreq: 0.1,
            payeeIds,
            maxLength: 100
          }),
          check
        )
        .beforeEach(() => {
          setClock(null);
          setSyncingMode('import');
          return db.execQuery(`
            DELETE FROM transactions;
            DELETE FROM payees;
            DELETE FROM payee_mapping;
          `);
        }),
      { numRuns: 300 }
    );
  }

  it('queries the correct transactions without filters', async () => {
    return runTest(arr => {
      let expectedIds = new Set(
        arr.filter(t => !t.tombstone && !t.is_child).map(t => t.id)
      );

      // Even though we're applying some filters, these are always
      // guaranteed to return the full split transaction so they
      // should take the optimized path
      let happyQuery = query('transactions')
        .filter({
          date: { $gt: '2017-01-01' }
        })
        .options({ splits: 'grouped' })
        .select(['*', 'payee.name']);

      // Make sure it's actually taking the happy path
      expect(isHappyPathQuery(happyQuery.serialize())).toBe(true);

      return {
        expectedIds,
        query: happyQuery
      };
    });
  });

  it(`queries the correct transactions with a filter`, async () => {
    return runTest(arr => {
      let expectedIds = new Set();

      // let parents = toGroup(
      //   arr.filter(t => t.is_parent),
      //   new Map(Object.entries(groupById(arr.filter(t => t.parent_id))))
      // );

      let parents = groupById(arr.filter(t => t.is_parent && !t.tombstone));
      let matched = new Set();

      // Pick out some ids to query
      let ids = arr.reduce((ids, trans, idx) => {
        if (idx % 2 === 0) {
          let amount = trans.amount == null ? 0 : trans.amount;
          let matches = (amount < -2 || amount > -1) && trans.payee > '';

          if (matches && isAlive(trans, parents)) {
            expectedIds.add(trans.parent_id || trans.id);
            matched.add(trans.id);
          }

          ids.push(trans.id);
        }

        return ids;
      }, []);

      // Because why not? It should deduplicate them
      ids = repeat(ids, 100);

      let unhappyQuery = query('transactions')
        .filter({
          id: [{ $oneof: ids }],
          payee: { $gt: '' },
          $or: [{ amount: { $lt: -2 } }, { amount: { $gt: -1 } }]
        })
        .options({ splits: 'grouped' })
        .select(['*', 'payee.name'])
        // Using this because we want `payee` to have ids for the above
        // filter regardless if it points to a dead one or not
        .withoutValidatedRefs();

      expect(isHappyPathQuery(unhappyQuery.serialize())).toBe(false);

      return {
        expectedIds,
        expectedMatchedIds: matched,
        query: unhappyQuery
      };
    });
  });
})

insertTransactions aliveTransactions expectTransactionOrder expectPagedData isAlive repeat

Summary: Queries with `splits: inline` return only non-parent transactions and filter out tombstones, with inline being the default option. Queries with `splits: none` return only parent transactions, excluding child transactions. Aggregate queries using `splits: grouped` accurately sum transaction amounts considering conditions on amounts and payee names, excluding tombstones and parents. A query without filters should return all non-child and non-tombstone transactions, maintaining expected ordering and paging behavior. A filtered query should effectively match transactions based on complex conditions, including deduplication of repeated IDs, ensuring matched and unmatched status correctness.


test('int(BigInt) should be reversed by Integer.toBigInt', () => {
    fc.assert(
      fc.property(
        fc.bigInt({ max: Integer.MAX_SAFE_VALUE.toBigInt(), min: Integer.MIN_SAFE_VALUE.toBigInt() }),
        bigint => bigint === int(bigint).toBigInt()
      )
    )
  })

Summary: Conversion of a `BigInt` to an `Integer` and back should return the original `BigInt`.


test('int.toString() should match Integer.toString()', () => {
    fc.assert(fc.property(fc.integer(), i => i.toString() === int(i).toString()))
  })

Summary: `int.toString()` should produce the same result as `Integer.toString()` when applied to the same integer value.


it('should sort requiredDVNs and optionalDVNs before encoding', async () => {
            fc.assert(
                fc.property(dvnsArbitrary, (dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnConfigUnsorted: UlnReadUlnConfig = {
                        executor: AddressZero,
                        optionalDVNThreshold: 0,
                        optionalDVNs: dvns,
                        requiredDVNs: dvns,
                    }

                    const ulnConfigSorted: UlnReadUlnConfig = {
                        ...ulnConfigUnsorted,
                        optionalDVNs: sortedDvns,
                        requiredDVNs: sortedDvns,
                    }

                    const ulnConfigEncodedUnsorted = ulnSdk.encodeUlnConfig(ulnConfigUnsorted)
                    const ulnConfigEncodedSorted = ulnSdk.encodeUlnConfig(ulnConfigSorted)
                    expect(ulnConfigEncodedSorted).toBe(ulnConfigEncodedUnsorted)
                }),
                { numRuns: 20 }
            )
        })

Summary: The encoding of `ulnConfig` should be consistent regardless of whether `requiredDVNs` and `optionalDVNs` are sorted.


it('should sort requiredDVNs and optionalDVNs', async () => {
            await fc.assert(
                fc.asyncProperty(channelIdArbitrary, dvnsArbitrary, async (eid, dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnConfigUnsorted: UlnReadUlnConfig = {
                        executor: AddressZero,
                        optionalDVNThreshold: 0,
                        optionalDVNs: dvns,
                        requiredDVNs: dvns,
                    }

                    const ulnConfigSorted: UlnReadUlnConfig = {
                        ...ulnConfigUnsorted,
                        optionalDVNs: sortedDvns,
                        requiredDVNs: sortedDvns,
                    }

                    // Let's check that both the sorted and the unsorted config produce the same transaction
                    const transactionUnsorted = await ulnSdk.setDefaultUlnConfig(eid, ulnConfigUnsorted)
                    const transactionsSorted = await ulnSdk.setDefaultUlnConfig(eid, ulnConfigSorted)
                    expect(transactionUnsorted).toEqual(transactionsSorted)

                    // And let's check that the encoding call is correct and the DVNs are sorted
                    expect(transactionsSorted.data).toBe(
                        ulnSdk.contract.contract.interface.encodeFunctionData('setDefaultReadLibConfigs', [
                            [
                                {
                                    eid,
                                    config: {
                                        executor: AddressZero,
                                        optionalDVNThreshold: 0,
                                        optionalDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNCount: sortedDvns.length,
                                        optionalDVNCount: sortedDvns.length,
                                    },
                                },
                            ],
                        ])
                    )
                }),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.setDefaultUlnConfig` should produce identical transactions for unsorted and sorted DVNs, and the encoded data should have DVNs sorted.


test('Integer.valueOf should be equivalent to the Integer.toBigInt', () => {
    fc.assert(
      fc.property(
        fc.bigInt({ max: Integer.MAX_SAFE_VALUE.toBigInt(), min: Integer.MIN_SAFE_VALUE.toBigInt() }),
        num => int(num).toBigInt() === int(num).valueOf()
      )
    )
  })

Summary: `Integer.valueOf` should return the same result as `Integer.toBigInt` for integers within the safe range.


test('Integer should be able to be used in the string interpolation', () => {
    fc.assert(
      fc.property(
        fc.bigInt({ max: Integer.MAX_SAFE_VALUE.toBigInt(), min: Integer.MIN_SAFE_VALUE.toBigInt() }),
        num => `string${int(num)}str` === 'string' + int(num).toString() + 'str'
      )
    )
  })

Summary: The `Integer` type supports string interpolation, ensuring that converting a big integer and interpolating it into a string produces the same result as concatenating its string representation.


it('should default the missing attributes', async () => {
            await fc.assert(
                fc.asyncProperty(channelIdArbitrary, dvnsArbitrary, async (eid, dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnUserConfig: UlnReadUlnUserConfig = {
                        requiredDVNs: dvns,
                    }
                    const ulnConfig: UlnReadUlnConfig = {
                        requiredDVNs: dvns,
                        executor: AddressZero,
                        optionalDVNThreshold: 0,
                        optionalDVNs: [],
                    }

                    // Let's check that both the sorted and the unsorted config produce the same transaction
                    const transactionsWithDefaults = await ulnSdk.setDefaultUlnConfig(eid, ulnUserConfig)
                    const transactionsWithFullConfig = await ulnSdk.setDefaultUlnConfig(eid, ulnConfig)
                    expect(transactionsWithDefaults).toEqual(transactionsWithFullConfig)

                    // And let's check that the encoding call is correct and the DVNs are sorted
                    expect(transactionsWithDefaults.data).toBe(
                        ulnSdk.contract.contract.interface.encodeFunctionData('setDefaultReadLibConfigs', [
                            [
                                {
                                    eid,
                                    config: {
                                        executor: ulnConfig.executor,
                                        optionalDVNThreshold: ulnConfig.optionalDVNThreshold,
                                        optionalDVNs: ulnConfig.optionalDVNs,
                                        requiredDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNCount: ulnConfig.requiredDVNs.length,
                                        optionalDVNCount: ulnConfig.optionalDVNs.length,
                                    },
                                },
                            ],
                        ])
                    )
                }),
                { numRuns: 20 }
            )
        })

Summary: Tests that setting a user configuration with missing attributes defaults to producing the same transaction as a fully specified configuration, ensuring the encoding call sorts DVNs correctly.


it('should return true if the configs are identical', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (channelId, oapp, ulnConfig) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(ulnSdk.hasAppUlnConfig(channelId, oapp, ulnConfig)).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The function `ulnSdk.hasAppUlnConfig` returns true if the configuration obtained for a given channel and app matches the provided configuration.


test('Integer should be able to use / operator as bigint', () => {
    fc.assert(
      fc.property(
        fc.bigInt({ max: Integer.MAX_SAFE_VALUE.toBigInt(), min: Integer.MIN_SAFE_VALUE.toBigInt() }),
        fc.bigInt({ max: Integer.MAX_SAFE_VALUE.toBigInt(), min: Integer.MIN_SAFE_VALUE.toBigInt() }).filter(n => n !== BigInt(0)),
        (num1, num2) =>
          // @ts-expect-error
          num1 / int(num2) === num1 / num2 &&
          // @ts-expect-error
          int(num1) / num2 === num1 / num2 &&
          // @ts-expect-error
          int(num1) / int(num2) === num1 / num2
      ))
  })

Summary: `Integer` division using the `/` operator should behave identically to `bigint` division within safe value ranges, without division by zero.


test('int(string) should match int(Integer)', () => {
    fc.assert(fc.property(fc.integer(), i => int(i).equals(int(i.toString()))))
  })

Summary: Creating an integer from a string representation should yield the same result as creating it directly from an integer, verified by their equality.


it('should return true if config has extra properties', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    fc.object(),
                    async (channelId, oapp, ulnConfig, extra) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(channelId, oapp, {
                                ...extra,
                                ...ulnConfig,
                            })
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` returns true when the configuration includes extra properties in addition to the expected `ulnConfig`.


test('Integer.multiply should be Commutative', () => {
    fc.assert(fc.property(arbitraryInteger(), arbitraryInteger(),
      (a, b) => a.multiply(b).equals(b.multiply(a))))
  })

Summary: The multiplication operation of the `Integer` class should be commutative, meaning `a.multiply(b)` should equal `b.multiply(a)` for arbitrary integers `a` and `b`.


it('should return true if configs with defaults are identical', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    dvnsArbitrary,
                    async (channelId, oapp, dvns) => {
                        const ulnUserConfig: UlnReadUlnUserConfig = {
                            requiredDVNs: dvns,
                        }
                        const ulnConfig: UlnReadUlnConfig = {
                            requiredDVNs: dvns,
                            optionalDVNs: [],
                            optionalDVNThreshold: 0,
                            executor: AddressZero,
                        }

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(ulnSdk.hasAppUlnConfig(channelId, oapp, ulnUserConfig)).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: Configurations with defaults should be considered identical, resulting in `ulnSdk.hasAppUlnConfig` returning true.


test('Integer.add should be Distributive', () => {
    fc.assert(fc.property(arbitraryInteger(), arbitraryInteger(), arbitraryInteger(),
      (a, b, c) => a.multiply(b.add(c)).equals(a.multiply(b).add(a.multiply(c)))))
  })

Summary: `Integer.add` should distribute over multiplication, ensuring that `a * (b + c)` is equal to `a * b + a * c` for arbitrary integers `a`, `b`, and `c`.


it('should return false if configs with defaults are not identical', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (channelId, oapp, ulnConfig) => {
                        // We only want to test againsts configs that are not
                        // equal to the default config
                        fc.pre(
                            ulnConfig.executor !== AddressZero ||
                                ulnConfig.optionalDVNThreshold !== 0 ||
                                ulnConfig.optionalDVNs.length !== 0
                        )

                        const ulnUserConfig: UlnReadUlnUserConfig = {
                            requiredDVNs: ulnConfig.requiredDVNs,
                        }

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(ulnSdk.hasAppUlnConfig(channelId, oapp, ulnUserConfig)).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` should return false when non-default ulnConfig settings are used contrary to default configurations.


it('should return true if the configs are identical except for the dvn casing', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (channelId, oapp, ulnConfig) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(channelId, oapp, {
                                ...ulnConfig,
                                requiredDVNs: ulnConfig.requiredDVNs.map(addChecksum),
                                optionalDVNs: ulnConfig.optionalDVNs.map(addChecksum),
                            })
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The test checks that `ulnSdk.hasAppUlnConfig` returns true when two configurations are identical except for the casing in `requiredDVNs` and `optionalDVNs`.


test('Integer.multiply should have 0 as identity', () => {
    fc.assert(fc.property(arbitraryInteger(), (a) => a.multiply(1).equals(a)))
  })

Summary: `Integer.multiply` with 1 should return the original integer.


test('Integer.div should have 0 as identity', () => {
    fc.assert(fc.property(arbitraryInteger(), (a) => a.div(1).equals(a)))
  })

Summary: Dividing an `Integer` by 1 should result in the original `Integer`.


it('should return true if the configs are identical except for the dvn sorting and casing', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (channelId, oapp, ulnConfig) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(channelId, oapp, {
                                ...ulnConfig,
                                requiredDVNs: ulnConfig.requiredDVNs.map(addChecksum).sort(compareBytes32Ascending),
                                optionalDVNs: ulnConfig.optionalDVNs.map(addChecksum).sort(compareBytes32Ascending),
                            })
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` returns true if two configurations are identical except for variations in sorting and casing of the DVNs.


test('Integer.greaterThanOrEqual should return true if a - b is positive or ZERO', () => {
      fc.assert(fc.property(
        arbitrarySameSignIntegers(),
        ({ a, b }) => a.subtract(b).isPositive() || a.subtract(b).isZero() ? a.greaterThanOrEqual(b) : !a.greaterThanOrEqual(b)))
    })

Summary: `Integer.greaterThanOrEqual` returns true when the result of `a - b` is positive or zero.


test('Integer.lessThanOrEqual should return true if a - b is ZERO or negative', () => {
      fc.assert(fc.property(
        arbitrarySameSignIntegers(),
        ({ a, b }) => a.subtract(b).isNegative() || a.subtract(b).isZero() ? a.lessThanOrEqual(b) : !a.lessThanOrEqual(b)))
    })

Summary: `Integer.lessThanOrEqual` should return true if the result of `a.subtract(b)` is zero or negative.


it('should return false if the optionalDVNThresholds are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    fc.integer(),
                    async (channelId, oapp, ulnConfig, optionalDVNThreshold) => {
                        fc.pre(optionalDVNThreshold !== ulnConfig.optionalDVNThreshold)

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(channelId, oapp, {
                                ...ulnConfig,
                                optionalDVNThreshold,
                            })
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: Checks if `hasAppUlnConfig` returns false when `optionalDVNThreshold` differs from `ulnConfig.optionalDVNThreshold`.


test('Integer.lessThanOrEqual should return true if a - b is ZERO or negative', () => {
      fc.assert(fc.property(
        arbitrarySameSignIntegers(),
        ({ a, b }) => a.subtract(b).isNegative() ? a.lessThan(b) : !a.lessThan(b)))
    })

Summary: `Integer.lessThanOrEqual` returns true when subtracting `b` from `a` results in zero or a negative value.


test('Integer.greaterThanOrEqual should return true if a is positive or ZERO', () => {
      fc.assert(fc.property(
        arbitraryDiffSignIntegers(),
        ({ a, b }) => a.isPositive() || a.isZero() ? a.greaterThanOrEqual(b) : !a.greaterThanOrEqual(b)))
    })

Summary: `Integer.greaterThanOrEqual` should return true when the first integer is positive or zero, and false otherwise.


it('should return false if the requiredDVNs are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    channelIdArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    dvnsArbitrary,
                    async (channelId, oapp, ulnConfig, extraRequiredDVNs) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(channelId, oapp, {
                                ...ulnConfig,
                                requiredDVNs: [...ulnConfig.requiredDVNs, ...extraRequiredDVNs],
                            })
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` should return false if `requiredDVNs` in the provided configuration differ from those in `ulnConfig`.


test('Integer.lessThanOrEqual should return true if a is ZERO or negative', () => {
      fc.assert(fc.property(
        arbitraryDiffSignIntegers(),
        ({ a, b }) => a.isNegative() || a.isZero() ? a.lessThanOrEqual(b) : !a.lessThanOrEqual(b)))
    })

Summary: `Integer.lessThanOrEqual` returns true when the first integer is zero or negative.


test('Integer.lessThanOrEqual should return true if a is ZERO or negative', () => {
      fc.assert(fc.property(
        arbitraryDiffSignIntegers(),
        ({ a, b }) => a.isNegative() ? a.lessThan(b) : !a.lessThan(b)))
    })

Summary: `Integer.lessThanOrEqual` should accurately return true when the first integer is zero or negative compared to the second integer's sign.


it('should sort requiredDVNs and optionalDVNs before encoding', async () => {
            fc.assert(
                fc.property(dvnsArbitrary, (dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnConfigUnsorted: Uln302UlnConfig = {
                        confirmations: BigInt(100),
                        optionalDVNThreshold: 0,
                        optionalDVNs: dvns,
                        requiredDVNs: dvns,
                    }

                    const ulnConfigSorted: Uln302UlnConfig = {
                        ...ulnConfigUnsorted,
                        optionalDVNs: sortedDvns,
                        requiredDVNs: sortedDvns,
                    }

                    const ulnConfigEncodedUnsorted = ulnSdk.encodeUlnConfig(ulnConfigUnsorted)
                    const ulnConfigEncodedSorted = ulnSdk.encodeUlnConfig(ulnConfigSorted)
                    expect(ulnConfigEncodedSorted).toBe(ulnConfigEncodedUnsorted)
                }),
                { numRuns: 20 }
            )
        })

Summary: Encoding should yield identical results whether `requiredDVNs` and `optionalDVNs` are sorted or unsorted.


it('should sort requiredDVNs and optionalDVNs', async () => {
            await fc.assert(
                fc.asyncProperty(endpointArbitrary, dvnsArbitrary, async (eid, dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnConfigUnsorted: Uln302UlnConfig = {
                        confirmations: BigInt(100),
                        optionalDVNThreshold: 0,
                        optionalDVNs: dvns,
                        requiredDVNs: dvns,
                    }

                    const ulnConfigSorted: Uln302UlnConfig = {
                        ...ulnConfigUnsorted,
                        optionalDVNs: sortedDvns,
                        requiredDVNs: sortedDvns,
                    }

                    // Let's check that both the sorted and the unsorted config produce the same transaction
                    const transactionUnsorted = await ulnSdk.setDefaultUlnConfig(eid, ulnConfigUnsorted)
                    const transactionsSorted = await ulnSdk.setDefaultUlnConfig(eid, ulnConfigSorted)
                    expect(transactionUnsorted).toEqual(transactionsSorted)

                    // And let's check that the encoding call is correct and the DVNs are sorted
                    expect(transactionsSorted.data).toBe(
                        ulnSdk.contract.contract.interface.encodeFunctionData('setDefaultUlnConfigs', [
                            [
                                {
                                    eid,
                                    config: {
                                        confirmations: BigInt(100),
                                        optionalDVNThreshold: 0,
                                        optionalDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNCount: sortedDvns.length,
                                        optionalDVNCount: sortedDvns.length,
                                    },
                                },
                            ],
                        ])
                    )
                }),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.setDefaultUlnConfig` produces the same transaction for both sorted and unsorted `requiredDVNs` and `optionalDVNs`, and the encoding call includes sorted DVNs with checksums.


it('should default the missing attributes', async () => {
            await fc.assert(
                fc.asyncProperty(endpointArbitrary, dvnsArbitrary, async (eid, dvns) => {
                    const sortedDvns = [...dvns].sort((a, b) => a.localeCompare(b))
                    const ulnUserConfig: Uln302UlnUserConfig = {
                        requiredDVNs: dvns,
                    }
                    const ulnConfig: Uln302UlnConfig = {
                        requiredDVNs: dvns,
                        confirmations: BigInt(0),
                        optionalDVNThreshold: 0,
                        optionalDVNs: [],
                    }

                    // Let's check that both the sorted and the unsorted config produce the same transaction
                    const transactionsWithDefaults = await ulnSdk.setDefaultUlnConfig(eid, ulnUserConfig)
                    const transactionsWithFullConfig = await ulnSdk.setDefaultUlnConfig(eid, ulnConfig)
                    expect(transactionsWithDefaults).toEqual(transactionsWithFullConfig)

                    // And let's check that the encoding call is correct and the DVNs are sorted
                    expect(transactionsWithDefaults.data).toBe(
                        ulnSdk.contract.contract.interface.encodeFunctionData('setDefaultUlnConfigs', [
                            [
                                {
                                    eid,
                                    config: {
                                        confirmations: ulnConfig.confirmations,
                                        optionalDVNThreshold: ulnConfig.optionalDVNThreshold,
                                        optionalDVNs: ulnConfig.optionalDVNs,
                                        requiredDVNs: sortedDvns.map(addChecksum),
                                        requiredDVNCount: ulnConfig.requiredDVNs.length,
                                        optionalDVNCount: ulnConfig.optionalDVNs.length,
                                    },
                                },
                            ],
                        ])
                    )
                }),
                { numRuns: 20 }
            )
        })

Summary: Missing attributes in a user configuration are defaulted, and both sorted and unsorted configurations produce identical transactions with properly encoded data reflecting the sorted required DVNs.


it('should return true if config has extra properties', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    fc.object(),
                    async (eid, oapp, ulnConfig, extra) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...extra,
                                    ...ulnConfig,
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The function `hasAppUlnConfig` should return true when the configuration object contains additional properties beyond what is specified in `ulnConfig`.


it('should return true if configs with defaults are identical', async () => {
            await fc.assert(
                fc.asyncProperty(endpointArbitrary, evmAddressArbitrary, dvnsArbitrary, async (eid, oapp, dvns) => {
                    const ulnUserConfig: Uln302UlnUserConfig = {
                        requiredDVNs: dvns,
                    }
                    const ulnConfig: Uln302UlnConfig = {
                        requiredDVNs: dvns,
                        optionalDVNs: [],
                        optionalDVNThreshold: 0,
                        confirmations: BigInt(0),
                    }

                    getAppUlnConfigSpy.mockReset()
                    getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                    await expect(
                        ulnSdk.hasAppUlnConfig(eid, oapp, ulnUserConfig, Uln302ConfigType.Receive)
                    ).resolves.toBeTruthy()
                }),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` should return true if the app's configuration matches the provided `ulnUserConfig` when defaults are applied.


it('should return false if configs with defaults are not identical', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (eid, oapp, ulnConfig) => {
                        // We only want to test againsts configs that are not
                        // equal to the default config
                        fc.pre(
                            ulnConfig.confirmations !== BigInt(0) ||
                                ulnConfig.optionalDVNThreshold !== 0 ||
                                ulnConfig.optionalDVNs.length !== 0
                        )

                        const ulnUserConfig: Uln302UlnUserConfig = {
                            requiredDVNs: ulnConfig.requiredDVNs,
                        }

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(eid, oapp, ulnUserConfig, Uln302ConfigType.Receive)
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The test checks that the function `ulnSdk.hasAppUlnConfig` returns false when the user configuration does not match the default configuration values.


it('should return true if the configs are identical except for the dvn casing', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (eid, oapp, ulnConfig) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    requiredDVNs: ulnConfig.requiredDVNs.map(addChecksum),
                                    optionalDVNs: ulnConfig.optionalDVNs.map(addChecksum),
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The property confirms that `hasAppUlnConfig` returns true when two configurations are identical except for the casing of `requiredDVNs` and `optionalDVNs` values.


it('should return true if the configs are identical except for the dvn sorting and casing', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    async (eid, oapp, ulnConfig) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    requiredDVNs: ulnConfig.requiredDVNs.map(addChecksum).sort(compareBytes32Ascending),
                                    optionalDVNs: ulnConfig.optionalDVNs.map(addChecksum).sort(compareBytes32Ascending),
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppUlnConfig` should return true when two configurations are identical except for differences in DVN sorting and casing.


it('should return false if the confirmations are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    fc.bigInt(),
                    async (eid, oapp, ulnConfig, confirmations) => {
                        fc.pre(confirmations !== ulnConfig.confirmations)

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    confirmations,
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The `ulnSdk.hasAppUlnConfig` function should return false when the provided confirmations differ from those in `ulnConfig`.


it('should return false if the optionalDVNThresholds are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    fc.integer(),
                    async (eid, oapp, ulnConfig, optionalDVNThreshold) => {
                        fc.pre(optionalDVNThreshold !== ulnConfig.optionalDVNThreshold)

                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    optionalDVNThreshold,
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: Returns false when `ulnSdk.hasAppUlnConfig` is called with an `optionalDVNThreshold` that differs from the one in `ulnConfig`.


it('should return false if the requiredDVNs are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    dvnsArbitrary,
                    async (eid, oapp, ulnConfig, extraRequiredDVNs) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    requiredDVNs: [...ulnConfig.requiredDVNs, ...extraRequiredDVNs],
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The test checks that `ulnSdk.hasAppUlnConfig` returns false when the `requiredDVNs` in the configuration differ from those in the `ulnConfig`.


it('should return false if the optionalDVNs are different', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    ulnConfigArbitrary,
                    dvnsArbitrary,
                    async (eid, oapp, ulnConfig, extraOptionalDVNs) => {
                        getAppUlnConfigSpy.mockReset()
                        getAppUlnConfigSpy.mockResolvedValue(ulnConfig)

                        await expect(
                            ulnSdk.hasAppUlnConfig(
                                eid,
                                oapp,
                                {
                                    ...ulnConfig,
                                    optionalDVNs: [...ulnConfig.optionalDVNs, ...extraOptionalDVNs],
                                },
                                Uln302ConfigType.Receive
                            )
                        ).resolves.toBeFalsy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The function `hasAppUlnConfig` should return false if the `optionalDVNs` in the given configuration differ from the expected configuration.


it('should return true if the configs are identical except for the executor casing', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    executorConfigArbitrary,
                    async (eid, oapp, executorConfig) => {
                        getAppExecutorConfigSpy.mockReset()
                        getAppExecutorConfigSpy.mockResolvedValue(executorConfig)

                        await expect(
                            ulnSdk.hasAppExecutorConfig(eid, oapp, {
                                ...executorConfig,
                                executor: addChecksum(executorConfig.executor),
                            })
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: The function `ulnSdk.hasAppExecutorConfig` should return true when configurations are identical except for the casing of the executor field.


it('should return true if config has extra properties', async () => {
            await fc.assert(
                fc.asyncProperty(
                    endpointArbitrary,
                    evmAddressArbitrary,
                    executorConfigArbitrary,
                    fc.object(),
                    async (eid, oapp, executorConfig, extra) => {
                        getAppExecutorConfigSpy.mockReset()
                        getAppExecutorConfigSpy.mockResolvedValue(executorConfig)

                        await expect(
                            ulnSdk.hasAppExecutorConfig(eid, oapp, {
                                ...extra,
                                ...executorConfig,
                            })
                        ).resolves.toBeTruthy()
                    }
                ),
                { numRuns: 20 }
            )
        })

Summary: `ulnSdk.hasAppExecutorConfig` returns true when the configuration includes extra properties beyond the executor configuration.


it('should reject if the address is a zeroish address', async () => {
            await fc.assert(
                fc.asyncProperty(pointArbitrary, zeroishAddressArbitrary, async (point, address) => {
                    const provider = new JsonRpcProvider()
                    const sdk = new EndpointV2(provider, point)

                    await expect(sdk.getUln302SDK(address)).rejects.toThrow(
                        /Uln302 cannot be instantiated: Uln302 address cannot be a zero value for Endpoint/
                    )
                })
            )
        })

Summary: `EndpointV2.getUln302SDK` should throw an error if the provided address is a zeroish address.


it('should return a ULN302 if the address is a non-zeroish address', async () => {
            await fc.assert(
                fc.asyncProperty(pointArbitrary, evmAddressArbitrary, async (point, address) => {
                    fc.pre(!isZero(address))

                    const provider = new JsonRpcProvider()

                    const sdk = new EndpointV2(provider, point)
                    const uln302 = await sdk.getUln302SDK(address)

                    expect(uln302).toBeInstanceOf(Uln302)
                    expect(uln302.point).toEqual({ eid: point.eid, address })
                })
            )
        })

Summary: Returns an instance of `Uln302` with the correct `point` if the address is non-zero.


it('should return a tuple if the call succeeds', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    evmAddressArbitrary,
                    fc.boolean(),
                    async (point, eid, oappAddress, libraryAddress, isDefault) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)

                        jest.spyOn(provider, 'call').mockResolvedValue(
                            sdk.contract.contract.interface.encodeFunctionResult('getReceiveLibrary', [
                                libraryAddress,
                                isDefault,
                            ])
                        )

                        await expect(sdk.getReceiveLibrary(oappAddress, eid)).resolves.toEqual([
                            addChecksum(libraryAddress),
                            isDefault,
                        ])
                    }
                )
            )
        })

Summary: A successful call to `sdk.getReceiveLibrary` should return a tuple containing the checksummed library address and a boolean indicating a default status.


it('should return undefined as the default lib if the call fails with LZ_DefaultReceiveLibUnavailable', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    async (point, eid, oappAddress) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)
                        // The LZ_DefaultReceiveLibUnavailable error
                        const error = { data: '0x78e84d06' }

                        jest.spyOn(provider, 'call').mockRejectedValue(error)

                        await expect(sdk.getReceiveLibrary(oappAddress, eid)).resolves.toEqual([undefined, true])
                    }
                )
            )
        })

Summary: When a call fails with the specific error `LZ_DefaultReceiveLibUnavailable`, `sdk.getReceiveLibrary` should return `[undefined, true]`.


it('should reject if call fails but not with LZ_DefaultReceiveLibUnavailable', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    async (point, eid, oappAddress) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)
                        const error = { data: '0x86957466' }

                        jest.spyOn(provider, 'call').mockRejectedValue(error)

                        await expect(sdk.getReceiveLibrary(oappAddress, eid)).rejects.toEqual(error)
                    }
                )
            )
        })

Summary: The test ensures that `sdk.getReceiveLibrary` rejects with a specific error when the provider's call fails, but not with the error `LZ_DefaultReceiveLibUnavailable`.


it('should return an address if the call succeeds', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    evmAddressArbitrary,
                    async (point, eid, oappAddress, libraryAddress) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)

                        jest.spyOn(provider, 'call').mockResolvedValue(
                            sdk.contract.contract.interface.encodeFunctionResult('getSendLibrary', [libraryAddress])
                        )

                        await expect(sdk.getSendLibrary(oappAddress, eid)).resolves.toEqual(addChecksum(libraryAddress))
                    }
                )
            )
        })

Summary: `getSendLibrary` should return a checksummed address if `provider.call` succeeds with the expected encoded function result.


it('should return undefined if the call fails with LZ_DefaultSendLibUnavailable', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    async (point, eid, oappAddress) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)
                        // The LZ_DefaultReceiveLibUnavailable error
                        const error = { data: '0x6c1ccdb5' }

                        jest.spyOn(provider, 'call').mockRejectedValue(error)

                        await expect(sdk.getSendLibrary(oappAddress, eid)).resolves.toEqual(undefined)
                    }
                )
            )
        })

Summary: `getSendLibrary` should return `undefined` if the provider call fails with the error `LZ_DefaultSendLibUnavailable`.


it('should reject if call fails but not with LZ_DefaultSendLibUnavailable', async () => {
            await fc.assert(
                fc.asyncProperty(
                    pointArbitrary,
                    endpointArbitrary,
                    evmAddressArbitrary,
                    async (point, eid, oappAddress) => {
                        const provider = new JsonRpcProvider()
                        const sdk = new EndpointV2(provider, point)
                        const error = { data: '0x86957466' }

                        jest.spyOn(provider, 'call').mockRejectedValue(error)

                        await expect(sdk.getSendLibrary(oappAddress, eid)).rejects.toEqual(error)
                    }
                )
            )
        })

Summary: Rejection occurs when a call fails but not due to `LZ_DefaultSendLibUnavailable`.


it('should call onStart & onSuccess when the callback resolves', async () => {
                await fc.assert(
                    fc.asyncProperty(fc.array(fc.anything()), fc.anything(), async (args, returnValue) => {
                        const fn = jest.fn().mockResolvedValue(returnValue)
                        const onStart = jest.fn().mockImplementation((logger: Logger) => logger.debug(`onStart`))
                        const onSuccess = jest.fn().mockImplementation((logger: Logger) => logger.debug(`onSuccess`))

                        await expect(withAsyncLogger(fn, { onStart, onSuccess })(...args)).resolves.toBe(returnValue)

                        expect(onStart).toHaveBeenCalledWith(expect.anything(), args)
                        expect(onSuccess).toHaveBeenCalledWith(expect.anything(), args, returnValue)
                        expect(onStart).toHaveBeenCalledBefore(onSuccess)
                    })
                )
            })

Summary: `withAsyncLogger` calls `onStart` and `onSuccess` with expected arguments and order when the provided callback resolves successfully.


it('should resolve if onSuccess call throws', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        fc.array(fc.anything()),
                        fc.anything(),
                        fc.anything(),
                        async (args, returnValue, loggerError) => {
                            const fn = jest.fn().mockResolvedValue(returnValue)
                            const onStart = jest.fn().mockImplementation((logger: Logger) => logger.debug(`onStart`))
                            const onSuccess = jest.fn().mockImplementation(() => {
                                throw loggerError
                            })

                            await expect(withAsyncLogger(fn, { onStart, onSuccess })(...args)).resolves.toBe(
                                returnValue
                            )

                            expect(onStart).toHaveBeenCalledWith(expect.anything(), args)
                            expect(onSuccess).toHaveBeenCalledWith(expect.anything(), args, returnValue)
                            expect(onStart).toHaveBeenCalledBefore(onSuccess)
                        }
                    )
                )
            })

Summary: `withAsyncLogger` resolves to the function's return value even if `onSuccess` throws an error.


it('should reject with the original error if onError callback throws', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        fc.array(fc.anything()),
                        fc.anything(),
                        fc.anything(),
                        async (args, error, loggerError) => {
                            const fn = jest.fn().mockRejectedValue(error)
                            const onStart = jest.fn().mockImplementation((logger: Logger) => logger.debug(`onStart`))
                            const onError = jest.fn().mockImplementation(() => {
                                throw loggerError
                            })

                            await expect(withAsyncLogger(fn, { onStart, onError })(...args)).rejects.toBe(error)

                            expect(onStart).toHaveBeenCalledWith(expect.anything(), args)
                            expect(onError).toHaveBeenCalledWith(expect.anything(), args, error)
                            expect(onStart).toHaveBeenCalledBefore(onError)
                        }
                    )
                )
            })

Summary: Rejects with the original error if the `onError` callback throws an error during its execution.


it('should remove any nulls or undefineds', () => {
            fc.assert(
                fc.property(fc.array(fc.oneof(transactionArbitrary, nullableArbitrary)), (transactions) => {
                    const flattened = flattenTransactions(transactions)

                    for (const transaction of flattened) {
                        expect(transaction).not.toBeNull()
                        expect(transaction).not.toBeUndefined()
                    }
                })
            )
        })

Summary: The property ensures `flattenTransactions` removes all `null` and `undefined` values from an array of transactions.


it('should return a map with containing all the transactions passed in', () => {
            fc.assert(
                fc.property(fc.array(transactionArbitrary), (transactions) => {
                    const grouped = groupTransactionsByEid(transactions)

                    for (const transaction of transactions) {
                        expect(grouped.get(transaction.point.eid)).toContain(transaction)
                    }
                })
            )
        })

Summary: `groupTransactionsByEid` returns a map where each transaction is grouped under its corresponding `eid`.


it('should preserve the order of transaction per group', () => {
            fc.assert(
                fc.property(fc.array(transactionArbitrary), (transactions) => {
                    const grouped = groupTransactionsByEid(transactions)

                    for (const transactionsForEid of grouped.values()) {
                        // Here we want to make sure that within a group of transactions,
                        // no transactions have changed order
                        //
                        // The logic here goes something like this:
                        // - We look for the indices of transactions from the grouped array in the original array
                        // - If two transactions swapped places, this array would then contain an inversion
                        //   (transaction at an earlier index in the grouped array would appear after a transaction
                        //   at a later index). So what we do is remove the inversions by sorting the array of indices
                        //   and make sure this sorted array matches the original one
                        const transactionIndices = transactionsForEid.map((t) => transactions.indexOf(t))
                        const sortedTransactionIndices = transactionIndices.slice().sort()

                        expect(transactionIndices).toEqual(sortedTransactionIndices)
                    }
                })
            )
        })

Summary: The order of transactions is preserved within each group after grouping by EID.


it('should not parse', () => {
                fc.assert(
                    fc.property(pointArbitrary, bad, (point, config) => {
                        expect(schema.safeParse({ point, config }).success).toBeFalsy()
                    })
                )
            })

Summary: Verifies that `schema.safeParse` fails when parsing objects containing specific `point` and `config` values.


it('should parse successfully', () => {
                fc.assert(
                    fc.property(vectorArbitrary, good, (vector, config) => {
                        expect(schema.safeParse({ vector, config }).success).toBeTruthy()
                    })
                )
            })

Summary: Parsing should succeed when given a `vector` and `config` that conform to the schema.


it('should work for non-negative bigints', () => {
            fc.assert(
                fc.property(fc.bigInt({ min: BigInt(0) }), (value) => {
                    expect(UIntBigIntSchema.parse(value)).toBe(value)
                })
            )
        })

Summary: `UIntBigIntSchema.parse` correctly processes non-negative bigint values, returning the original value.


it('should call forEach correctly', () => {
                fc.assert(
                    fc.property(fc.array(fc.tuple(keyArbitrary, valueArbitrary)), (entries) => {
                        const map = new TestMap(entries)
                        const callback = jest.fn()

                        map.forEach(callback)

                        // We'll get the entries from the map since the original entries
                        // might contain duplicates
                        const mapEntries = Array.from(map.entries())
                        expect(callback).toHaveBeenCalledTimes(mapEntries.length)

                        for (const [key, value] of mapEntries) {
                            expect(callback).toHaveBeenCalledWith(value, key, map)
                        }
                    })
                )
            })

Summary: The `forEach` method should invoke the callback with each key-value pair and the map, matching the number of unique entries in the map.


it('should use orElse if a key is not defined', () => {
                fc.assert(
                    fc.property(keyArbitrary, valueArbitrary, valueArbitrary, (key, value, orElseValue) => {
                        const map = new TestMap()
                        const orElse = jest.fn().mockReturnValue(orElseValue)

                        // Sanity check first
                        expect(map.has(key)).toBeFalsy()

                        // If the key has not been set, the map should use orElse
                        expect(map.getOrElse(key, orElse)).toBe(orElseValue)

                        // Set a value first
                        map.set(key, value)

                        // And check that orElse is not being used
                        expect(map.getOrElse(key, orElse)).toBe(value)

                        // Now delete the value
                        map.delete(key)

                        // And check that orElse is being used again
                        expect(map.getOrElse(key, orElse)).toBe(orElseValue)
                    })
                )
            })

Summary: The test confirms that `getOrElse` returns a fallback value via `orElse` if a key is not present in the map, and the actual value if the key is present.


it('should normalize a peer correctly', () => {
                fc.assert(
                    fc.property(evmEndpointArbitrary, evmAddressArbitrary, (eid, address) => {
                        const normalized = normalizePeer(address, eid)
                        const denormalized = denormalizePeer(normalized, eid)

                        expect(denormalized).toBe(address)
                    })
                )
            })

Summary: `normalizePeer` and `denormalizePeer` should ensure the denormalized output matches the original address given the same endpoint.


it('should normalize a nullish value to empty bytes', () => {
                fc.assert(
                    fc.property(aptosEndpointArbitrary, nullishArbitrary, (eid, address) => {
                        const normalized = normalizePeer(address, eid)
                        const denormalized = denormalizePeer(normalized, eid)

                        expect(normalized).toEqual(new Uint8Array(32))
                        expect(isZero(normalized)).toBe(true)
                        expect(isZero(denormalized)).toBe(true)
                    })
                )
            })

Summary: Normalization of a nullish value should result in an empty `Uint8Array` of size 32, and both normalized and denormalized outputs should consist only of zeros.


it('should normalize a peer correctly', () => {
                fc.assert(
                    fc.property(aptosEndpointArbitrary, aptosAddressArbitrary, (eid, address) => {
                        const normalized = normalizePeer(address, eid)
                        const denormalized = denormalizePeer(normalized, eid)

                        expect(denormalized).toBe(address)
                    })
                )
            })

Summary: `normalizePeer` followed by `denormalizePeer` should return the original address when using the same endpoint ID.


it('should normalize a nullish value to empty bytes', () => {
                fc.assert(
                    fc.property(solanaEndpointArbitrary, nullishArbitrary, (eid, address) => {
                        const normalized = normalizePeer(address, eid)
                        const denormalized = denormalizePeer(normalized, eid)

                        expect(normalized).toEqual(new Uint8Array(32))
                        expect(isZero(normalized)).toBe(true)
                        expect(isZero(denormalized)).toBe(true)
                    })
                )
            })

Summary: A nullish value should be normalized to a 32-byte zero-filled `Uint8Array`, and its denormalization should also result in zero-filled data.


it('should normalize a peer correctly', () => {
                fc.assert(
                    fc.property(solanaEndpointArbitrary, solanaAddressArbitrary, (eid, address) => {
                        const normalized = normalizePeer(address, eid)
                        const denormalized = denormalizePeer(normalized, eid)

                        expect(denormalized).toBe(address)
                    })
                )
            })

Summary: Normalizing and then denormalizing a peer with an address and endpoint should result in the original address.


it('should return true for arrays containing the same values', () => {
            fc.assert(
                fc.property(arrayArbitrary, (array) => {
                    expect(isDeepEqual(array, [...array])).toBeTruthy()
                    expect(isDeepEqual([...array], array)).toBeTruthy()
                })
            )
        })

Summary: `isDeepEqual` returns true for arrays containing identical values in the same order.


it('should return false for arrays containing different values', () => {
            fc.assert(
                fc.property(arrayArbitrary, arrayArbitrary, (arrayA, arrayB) => {
                    // We'll do a very simplified precondition - we'll only run tests when the first elements are different
                    fc.pre(!isDeepEqual(arrayA[0], arrayB[0]))

                    expect(isDeepEqual(arrayA, arrayB)).toBeFalsy()
                    expect(isDeepEqual(arrayB, arrayA)).toBeFalsy()
                })
            )
        })

Summary: `isDeepEqual` returns false for arrays with different first elements.


it('should return false for arrays containing more values', () => {
            fc.assert(
                fc.property(arrayArbitrary, fc.anything(), (array, extraValue) => {
                    expect(isDeepEqual(array, [...array, extraValue])).toBeFalsy()
                    expect(isDeepEqual([...array, extraValue], array)).toBeFalsy()
                })
            )
        })

Summary: `isDeepEqual` returns false when comparing an array to the same array with an additional value.


it('should return true for sets containing the same values', () => {
            fc.assert(
                fc.property(arrayArbitrary, (array) => {
                    const setA = new Set(array)
                    const setB = new Set(array)

                    expect(isDeepEqual(setA, setB)).toBeTruthy()
                    expect(isDeepEqual(setB, setA)).toBeTruthy()
                })
            )
        })

Summary: The property should hold that two sets created from the same array have deep equality.


it('should return true for maps containing the same values', () => {
            fc.assert(
                fc.property(entriesArbitrary, (entries) => {
                    const mapA = new Map(entries)
                    const mapB = new Map(entries)

                    expect(isDeepEqual(mapA, mapB)).toBeTruthy()
                    expect(isDeepEqual(mapB, mapA)).toBeTruthy()
                })
            )
        })

Summary: `isDeepEqual` returns true for two maps containing the same values.


it('should return true for objects containing the same values', () => {
            fc.assert(
                fc.property(
                    fc.record({
                        value: fc.anything(),
                    }),
                    (object) => {
                        expect(isDeepEqual(object, { ...object })).toBeTruthy()
                        expect(isDeepEqual({ ...object }, object)).toBeTruthy()
                    }
                )
            )
        })

Summary: `isDeepEqual` returns true when comparing an object with itself, regardless of syntactic duplication.


it('should return false for objects containing different values', () => {
            fc.assert(
                fc.property(
                    fc.record({
                        value: fc.anything(),
                    }),
                    fc.anything(),
                    (object, value) => {
                        fc.pre(!isDeepEqual(object.value, value))

                        expect(isDeepEqual(object, { value })).toBeFalsy()
                        expect(isDeepEqual({ value }, object)).toBeFalsy()
                    }
                )
            )
        })

Summary: Verifies that `isDeepEqual` returns false for objects with mismatched values compared to another value.


it('should sign a transaction', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        endpointArbitrary,
                        solanaAddressArbitrary,
                        keypairArbitrary,
                        keypairArbitrary,
                        async (eid, address, sender, recipient) => {
                            const transfer = SystemProgram.transfer({
                                fromPubkey: sender.publicKey,
                                toPubkey: recipient.publicKey,
                                lamports: 49,
                            })

                            const connection = new Connection('http://soyllama.com')
                            const omniSigner = new OmniSignerSolana(eid, connection, sender)

                            const transaction = new Transaction().add(transfer)
                            transaction.recentBlockhash = 'EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k'
                            transaction.feePayer = sender.publicKey

                            const omniTransaction: OmniTransaction = {
                                point: { eid, address },
                                data: serializeTransactionMessage(transaction),
                            }

                            const signature = await omniSigner.sign(omniTransaction)
                            const serializedTransaction = (transaction.sign(sender), transaction.serialize())

                            expect(deserializeTransactionBuffer(signature)).toEqual(serializedTransaction)
                        }
                    )
                )
            })

Summary: A transaction signed by `OmniSignerSolana` should match the serialized transaction signed manually by a `sender`.


it('should sign and send a transaction', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        endpointArbitrary,
                        solanaAddressArbitrary,
                        keypairArbitrary,
                        keypairArbitrary,
                        fc.string(),
                        async (eid, address, sender, recipient, transactionHash) => {
                            sendAndConfirmTransactionMock.mockResolvedValue(transactionHash)

                            const transfer = SystemProgram.transfer({
                                fromPubkey: sender.publicKey,
                                toPubkey: recipient.publicKey,
                                lamports: 49,
                            })

                            const connection = new Connection('http://soyllama.com')
                            const omniSigner = new OmniSignerSolana(eid, connection, sender)

                            const transaction = new Transaction().add(transfer)
                            transaction.recentBlockhash = 'EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k'
                            transaction.feePayer = sender.publicKey

                            const omniTransaction: OmniTransaction = {
                                point: { eid, address },
                                data: serializeTransactionMessage(transaction),
                            }

                            const response = await omniSigner.signAndSend(omniTransaction)
                            expect(response).toEqual({
                                transactionHash,
                                wait: expect.any(Function),
                            })

                            expect(await response.wait()).toEqual({ transactionHash })
                        }
                    )
                )
            })

Summary: The property ensures that a transaction, signed by `OmniSignerSolana` using arbitrary endpoints, addresses, and keypairs, is successfully sent and that the response matches the expected transaction hash, including a wait function that confirms the transaction hash.


it('should throw an error', async () => {
                await fc.assert(
                    fc.asyncProperty(
                        endpointArbitrary,
                        solanaAddressArbitrary,
                        keypairArbitrary,
                        keypairArbitrary,
                        async (eid, address, sender, recipient) => {
                            const transfer = SystemProgram.transfer({
                                fromPubkey: sender.publicKey,
                                toPubkey: recipient.publicKey,
                                lamports: 49,
                            })

                            const connection = new Connection('http://soyllama.com')
                            const multiSigAddress = PublicKey.default
                            const wallet = Keypair.generate()
                            const omniSigner: OmniSigner = new OmniSignerSolanaSquads(
                                eid,
                                connection,
                                multiSigAddress,
                                wallet
                            )

                            const transaction = new Transaction().add(transfer)
                            transaction.recentBlockhash = 'EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k'
                            transaction.feePayer = sender.publicKey

                            const omniTransaction: OmniTransaction = {
                                point: { eid, address },
                                data: serializeTransactionMessage(transaction),
                            }

                            await expect(omniSigner.sign(omniTransaction)).rejects.toThrow(
                                'OmniSignerSolanaSquads does not support the sign() method. Please use signAndSend().'
                            )
                        }
                    )
                )
            })

Summary: An error should be thrown when attempting to call `sign` on `OmniSignerSolanaSquads`, indicating that the method is not supported and `signAndSend` should be used instead.