Setting up market tests

This commit is contained in:
Ben 2024-11-21 15:10:53 +01:00
parent 339cf2b824
commit f67e67c493
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
5 changed files with 50 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using CodexContractsPlugin;
using CodexContractsPlugin.Marketplace;
using GethPlugin;
using Logging;
@ -18,18 +19,29 @@ namespace GethConnector
return null;
}
var gethNode = new CustomGethNode(log, GethInput.GethHost, GethInput.GethPort, GethInput.PrivateKey);
var config = GetCodexMarketplaceConfig(gethNode, GethInput.MarketplaceAddress);
var contractsDeployment = new CodexContractsDeployment(
config: config,
marketplaceAddress: GethInput.MarketplaceAddress,
abi: GethInput.ABI,
tokenAddress: GethInput.TokenAddress
);
var gethNode = new CustomGethNode(log, GethInput.GethHost, GethInput.GethPort, GethInput.PrivateKey);
var contracts = new CodexContractsAccess(log, gethNode, contractsDeployment);
return new GethConnector(gethNode, contracts);
}
private static MarketplaceConfig GetCodexMarketplaceConfig(IGethNode gethNode, string marketplaceAddress)
{
var func = new ConfigurationFunctionBase();
var response = gethNode.Call<ConfigurationFunctionBase, ConfigurationOutputDTO>(marketplaceAddress, func);
return response.ReturnValue1;
}
private GethConnector(IGethNode gethNode, ICodexContracts codexContracts)
{
GethNode = gethNode;

View File

@ -1,14 +1,18 @@
namespace CodexContractsPlugin
using CodexContractsPlugin.Marketplace;
namespace CodexContractsPlugin
{
public class CodexContractsDeployment
{
public CodexContractsDeployment(string marketplaceAddress, string abi, string tokenAddress)
public CodexContractsDeployment(MarketplaceConfig config, string marketplaceAddress, string abi, string tokenAddress)
{
Config = config;
MarketplaceAddress = marketplaceAddress;
Abi = abi;
TokenAddress = tokenAddress;
}
public MarketplaceConfig Config { get; }
public string MarketplaceAddress { get; }
public string Abi { get; }
public string TokenAddress { get; }

View File

@ -4,6 +4,7 @@ using GethPlugin;
using KubernetesWorkflow;
using KubernetesWorkflow.Types;
using Logging;
using Newtonsoft.Json;
using Utils;
namespace CodexContractsPlugin
@ -34,6 +35,7 @@ namespace CodexContractsPlugin
try
{
var result = DeployContract(container, workflow, gethNode);
workflow.Stop(containers, waitTillStopped: false);
Log("Container stopped.");
return result;
@ -75,9 +77,20 @@ namespace CodexContractsPlugin
Time.WaitUntil(() => interaction.IsSynced(marketplaceAddress, abi), nameof(DeployContract));
Log("Synced. Codex SmartContracts deployed.");
Log("Synced. Codex SmartContracts deployed. Getting configuration...");
return new CodexContractsDeployment(marketplaceAddress, abi, tokenAddress);
var config = GetMarketplaceConfiguration(marketplaceAddress, gethNode);
Log("Got config: " + JsonConvert.SerializeObject(config));
return new CodexContractsDeployment(config, marketplaceAddress, abi, tokenAddress);
}
private MarketplaceConfig GetMarketplaceConfiguration(string marketplaceAddress, IGethNode gethNode)
{
var func = new ConfigurationFunctionBase();
var response = gethNode.Call<ConfigurationFunctionBase, ConfigurationOutputDTO>(marketplaceAddress, func);
return response.ReturnValue1;
}
private void EnsureCompatbility(string abi, string bytecode)

View File

@ -23,9 +23,8 @@ namespace CodexContractsPlugin
public string GetTokenAddress(string marketplaceAddress)
{
log.Debug(marketplaceAddress);
var function = new GetTokenFunction();
return gethNode.Call<GetTokenFunction, string>(marketplaceAddress, function);
var function = new TokenFunctionBase();
return gethNode.Call<TokenFunctionBase, string>(marketplaceAddress, function);
}
public string GetTokenName(string tokenAddress)
@ -111,11 +110,6 @@ namespace CodexContractsPlugin
}
}
[Function("token", "address")]
public class GetTokenFunction : FunctionMessage
{
}
[Function("name", "string")]
public class GetTokenNameFunction : FunctionMessage
{

View File

@ -1,4 +1,8 @@
using System;
using CodexContractsPlugin;
using CodexTests;
using GethPlugin;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -6,7 +10,15 @@ using System.Threading.Tasks;
namespace CodexReleaseTests.MarketTests
{
internal class ContractSuccessfulTest
[TestFixture]
public class ContractSuccessfulTest : AutoBootstrapDistTest
{
[Test]
public void ContractSuccessful()
{
var geth = Ci.StartGethNode(s => s.IsMiner());
var contracts = Ci.DeployCodexContracts(geth);
}
}
}