github.com/smartcontractkit/chainlink-terra@v0.1.4/tests/e2e/smoke/gauntlet_test.go (about) 1 package smoke_test 2 3 import ( 4 "fmt" 5 "math/big" 6 "os" 7 "path/filepath" 8 9 . "github.com/onsi/ginkgo/v2" 10 . "github.com/onsi/gomega" 11 "github.com/smartcontractkit/chainlink-terra/tests/e2e" 12 "github.com/smartcontractkit/chainlink-terra/tests/e2e/common" 13 tc "github.com/smartcontractkit/chainlink-terra/tests/e2e/smoke/common" 14 "github.com/smartcontractkit/chainlink-terra/tests/e2e/utils" 15 "github.com/smartcontractkit/helmenv/environment" 16 "github.com/smartcontractkit/integrations-framework/actions" 17 "github.com/smartcontractkit/integrations-framework/gauntlet" 18 ) 19 20 var _ = Describe("Terra Gauntlet @gauntlet", func() { 21 var ( 22 gd *e2e.GauntletDeployer 23 state *tc.OCRv2State 24 ) 25 26 BeforeEach(func() { 27 By("Deploying the environment", func() { 28 gd = &e2e.GauntletDeployer{ 29 Version: "local", 30 } 31 state = &tc.OCRv2State{} 32 state.DeployEnv(1, false) 33 state.SetupClients() 34 if state.Nets.Default.ContractsDeployed() { 35 err := state.LoadContracts() 36 Expect(err).ShouldNot(HaveOccurred()) 37 } 38 39 state.OCConfig, state.NodeKeysBundle, state.Err = common.DefaultOffChainConfigParamsFromNodes(state.Nodes) 40 Expect(state.Err).ShouldNot(HaveOccurred()) 41 42 // Remove the stuff below when the token:deploy command is fixed to work for automated testing 43 cd := e2e.NewTerraContractDeployer(state.Nets.Default) 44 linkToken, err := cd.DeployLinkTokenContract() 45 Expect(err).ShouldNot(HaveOccurred(), "Failed to deploy link token") 46 gd.LinkToken = linkToken.Address() 47 err = common.FundOracles(state.Nets.Default, state.NodeKeysBundle, big.NewFloat(5e12)) 48 Expect(err).ShouldNot(HaveOccurred()) 49 // 50 }) 51 By("Setup Gauntlet", func() { 52 cwd, err := os.Getwd() 53 Expect(err).ShouldNot(HaveOccurred(), "Failed to get the working directory") 54 err = os.Chdir(filepath.Join(cwd + "../../../..")) 55 Expect(err).ShouldNot(HaveOccurred()) 56 57 gd.Cli, err = gauntlet.NewGauntlet() 58 Expect(err).ShouldNot(HaveOccurred()) 59 60 terraNodeUrl, err := state.Env.Charts.Connections("localterra").LocalURLByPort("lcd", environment.HTTP) 61 Expect(err).ShouldNot(HaveOccurred()) 62 gd.Cli.NetworkConfig = e2e.GetDefaultGauntletConfig(terraNodeUrl) 63 err = gd.Cli.WriteNetworkConfigMap(utils.Networks) 64 Expect(err).ShouldNot(HaveOccurred(), "failed to write the .env file") 65 gd.Cli.NetworkConfig["LINK"] = gd.LinkToken 66 }) 67 }) 68 69 Describe("Run Gauntlet Commands", func() { 70 It("should deploy ocr and accept a proposal", func() { 71 // upload artifacts 72 gd.Upload() 73 74 // Uncomment the below when token:deploy command is fixed for automated testing 75 // token:deploy 76 // gd.LinkToken = gd.DeployToken() 77 // gd.Cli.NetworkConfig["LINK"] = gd.LinkToken 78 // err := common.FundOracles(state.Nets.Default, state.NodeKeysBundle, big.NewFloat(5e12)) 79 // Expect(err).ShouldNot(HaveOccurred()) 80 // 81 82 // deploy access controllers 83 gd.BillingAccessController = gd.DeployBillingAccessController() 84 gd.RequesterAccessController = gd.DeployRequesterAccessController() 85 86 // write the updated values for link and access controllers to the .env file 87 err := gd.Cli.WriteNetworkConfigMap(utils.Networks) 88 Expect(err).ShouldNot(HaveOccurred(), "Failed to write the updated .env file") 89 90 // flags:deploy 91 gd.Flags = gd.DeployFlags(gd.BillingAccessController, gd.RequesterAccessController) 92 93 // deviation_flagging_validator:deploy 94 gd.DeviationFlaggingValidator = gd.DeployDeviationFlaggingValidator(gd.Flags, 8000) 95 96 // ocr2:deploy 97 gd.OCR, gd.RddPath = gd.DeployOcr() 98 99 // ocr2:set_billing 100 gd.SetBilling(gd.OCR, gd.RddPath) 101 102 // ocr2:begin_proposal 103 gd.ProposalId = gd.BeginProposal(gd.OCR, gd.RddPath) 104 105 // ocr2:propose_config 106 gd.ProposeConfig(gd.OCR, gd.ProposalId, gd.RddPath) 107 108 // ocr2:propose_offchain_config 109 gd.ProposeOffchainConfig(gd.OCR, gd.ProposalId, gd.RddPath) 110 111 // ocr2:finalize_proposal 112 gd.ProposalDigest = gd.FinalizeProposal(gd.OCR, gd.ProposalId, gd.RddPath) 113 114 // ocr2:accept_proposal 115 gd.AcceptProposal(gd.OCR, gd.ProposalId, gd.ProposalDigest, gd.RddPath) 116 117 // ocr2:inspect 118 results := gd.OcrInspect(gd.OCR, gd.RddPath) 119 Expect(len(results)).Should(Equal(28), "Did not find the expected number of results in the output") 120 for _, v := range results { 121 Expect(v.Pass).Should(Equal(true), fmt.Sprintf("%s expected %s but actually %s", v.Key, v.Expected, v.Actual)) 122 123 } 124 }) 125 }) 126 127 AfterEach(func() { 128 By("Tearing down the environment", func() { 129 err := actions.TeardownSuite(state.Env, nil, "logs", nil) 130 Expect(err).ShouldNot(HaveOccurred()) 131 }) 132 }) 133 })