Case Study

How Origin Protocol Uses Virtual TestNets for Integration Testing

Organization: Origin Protocol

Industry: DeFi

How Origin Protocol Uses Virtual TestNets for Integration Testing

"State syncing is a major benefit for us as Origin Protocol involves a lot of contracts that use Oracles. Otherwise, we’d end up with data aging issues and our prices wouldn’t be up-to-date."

Antoine Codogno

Frontend engineer at Origin Protocol

Origin Protocol is an Ethereum-based project building breakthrough DeFi primitives at the forefront of liquid staking and yield generation. The protocol’s flagship liquid staking token, Origin Ether (OETH), is one of the space’s most versatile LSTs, boasting diverse integrations on Ethereum and Arbitrum, with Base deployment in the works. 

Users can also harness Origin Dollar (OUSD) to unlock superior stablecoin yield securely and fully on-chain. OGN serves as the protocol’s governance and value-accrual token, with a share of revenue from all of Origin’s platforms accruing to OGN stakers. 

Under the hood, the protocol features multiple Solidity contracts, an indexing service, and a frontend featuring both client- and server-side applications. Origin’s infrastructure and all-in-one dapp are developed by a veteran team of on-chain and off-chain engineers.

The on-chain team consists of Solidity developers working on the protocol contracts and preparing them for deployment to Tenderly Virtual TestNets, a zero-setup development infrastructure. The off-chain team then takes over and integrates Virtual TestNets for further development and testing. 

What the Origin Protocol testing flow looks like

During the early stages of development, Origin Protocol’s on-chain team uses Hardhat and Foundry on their local machines. After developing smart contracts and running different types of local tests, the team submits the contracts for an audit for an in-depth analysis. 

Initially, the Solidity team needed to set up a local Anvil node and fork a production chain for the frontend team to build the frontend and verify everything was working as expected. This setup carried additional overhead, requiring greater infrastructure management. Additionally, plugging indexers into this type of infrastructure was particularly challenging as everything was running on local machines. 

Now, after ensuring code correctness, the Solidity team can simply deploy the smart contracts to Virtual TestNets using the same Foundry and Hardhat scripts. At this stage, the frontend and backend teams integrate Virtual TestNets as a staging environment for integration testing together with indexing services.

Once the integration testing is complete, new deployments are proposed through governance, with stakeholders voting to deploy the contracts on-chain. With Virtual TestNets, contract addresses stay the same upon deployment, so the team just needs to replace a Virtual TestNet RPC with a production network RPC. 

Using Virtual TestNets for integration testing

The frontend team runs numerous manual tests on their dapp with Virtual TestNets as their staging environment. Aside from Virtual TestNets, their tech stack also features other industry-standard components, including Wagmi, React, and Remix. 

Staging Origin Protocol’s smart contracts, frontend, and backend on Virtual TestNets provides the team with several advantages:

  • Having a registry and library of contract addresses and ABIs per network in a single place.
  • Testing under realistic on-chain conditions without integrating with a completely new network.
  • Using the same smart contract code, addresses, proxies, and chain IDs for frontend and backend integration testing as on-chain.
  • Recreating an execution environment and replicating bugs to better understand what happened in a transaction.
  • Funding and impersonating accounts for custom testing scenarios thanks to an unlimited faucet and unlocked public assets. 
  • Syncing with the latest state of Ethereum Mainnet, as well as other networks they’re building on for up-to-date data. 
State syncing is a major benefit for us as Origin Protocol involves a lot of contracts that use Oracles. Otherwise, we’d end up with data aging issues and our prices wouldn’t be up-to-date. – Antoine Codogno, a frontend engineer at Origin Protocol

Bug resolution with Virtual TestNets

Virtual TestNets come with a built-in explorer and debugging tools, enabling the Origin Protocol teams to quickly address issues that arise during testing. 

Being able to replicate a bug by recreating the execution conditions and dive into the code to see why and where a bug happened is definitely a great help for us. – Antoine Codogno, a frontend engineer at Origin Protocol

The built-in explorer provides a list of executed transactions on a Virtual TestNet. The Origin Protocol can see if all the transactions execute as expected. If a transaction reverts, the team can use the debugging tools to dive into contract code, examine the full execution stack trace, and see where it fails.

The future with Virtual TestNets

Origin Protocol’s use of Virtual TestNets highlights the technology’s value as the next-generation development and testing infrastructure in Web3. Features like state syncing and built-in exploration and debugging tools make Virtual TestNets a powerful addition to any Web3 developer’s stack, enabling more efficient and streamlined testing workflows.