integrations-framework

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: MIT

README

Go Report Card Tests Lint

A framework for interacting with chainlink nodes, environments, and other blockchain systems. The framework is primarilly intended to facillitate testing chainlink features and stability.

WIP

This framework is still very much a work in progress, and will have frequent changes, many of which will probably be breaking.

Setup

Install CLI

make install_cli

Usage

A simple example on deploying and interaction with a simple contract using this framework and Ginkgo

var _ = Describe("Basic Contract Interactions", func() {
  var suiteSetup *actions.DefaultSuiteSetup
  var defaultWallet client.BlockchainWallet

  BeforeEach(func() {
    By("Deploying the environment", func() {
      confFileLocation, err := filepath.Abs("../") // Get the absolute path of the test suite's root directory
      Expect(err).ShouldNot(HaveOccurred())
      suiteSetup, err = actions.DefaultLocalSetup(
        environment.NewChainlinkCluster(0),
        client.NewNetworkFromConfig,
        confFileLocation, // Directory where config.yml is placed
      )
      Expect(err).ShouldNot(HaveOccurred())
      defaultWallet = suiteSetup.Wallets.Default()
    })
  })

  It("exercises basic contract usage", func() {
    By("deploying the storage contract", func() {
      // Deploy storage
      storeInstance, err := suiteSetup.Deployer.DeployStorageContract(defaultWallet)
      Expect(err).ShouldNot(HaveOccurred())

      testVal := big.NewInt(5)

      // Interact with contract
      err = storeInstance.Set(testVal)
      Expect(err).ShouldNot(HaveOccurred())
      val, err := storeInstance.Get(context.Background())
      Expect(err).ShouldNot(HaveOccurred())
      Expect(val).To(Equal(testVal))
     })
  })

  AfterEach(func() {
    By("Tearing down the environment", suiteSetup.TearDown())
  })
})

Execution Environment

Ephemeral environments are automatically deployed with Kubernetes. To run tests, you either need a deployed cluster in an environment, or a local installation.

Locally

When running tests locally, it's advised to use minikube. To spin up a cluster, use:

minikube start
Remotely

To run against a remote Kubernetes cluster, ensure your current context is the cluster you want to run against as the framework always uses current context.

Test Execution

This framework advises the use of Ginkgo for test execution, but tests still can be ran with the go CLI.

Ginkgo

Run:

ginkgo -r
Go

Run:

go test ./..
Volume tests
NETWORK="ethereum_geth_performance" make test_performance
Build contracts

Example of generating go bindings for Ethereum contracts

ifcli build_contracts -c config.yml
Create environment

Example of creating environment with one Chainlink node and Geth dev network

ifcli create_env -n ethereum_geth -t chainlink -c 1

Directories

Path Synopsis
cli
cmd
Package client handles connections between chainlink nodes and different blockchain networks
Package client handles connections between chainlink nodes and different blockchain networks
Package config enables loading and utilizing configuration options for different blockchain networks
Package config enables loading and utilizing configuration options for different blockchain networks
Package contracts handles deployment, management, and interactions of smart contracts on various chains
Package contracts handles deployment, management, and interactions of smart contracts on various chains
cmd
suite

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL