Commit 71f875bd authored by khvostenko's avatar khvostenko

"stratis" substituted with "destream" in code

parent a2ce77fa
...@@ -65,7 +65,7 @@ namespace DeStream.Bitcoin.Cli ...@@ -65,7 +65,7 @@ namespace DeStream.Bitcoin.Cli
builder.AppendLine(); builder.AppendLine();
builder.AppendLine("Command line arguments:"); builder.AppendLine("Command line arguments:");
builder.AppendLine(); builder.AppendLine();
builder.AppendLine("[network-name] Name of the network - e.g. \"stratis\", \"stratismain\", \"stratistest\", \"bitcoinmain\", \"bitcointest\"."); builder.AppendLine("[network-name] Name of the network - e.g. \"destream\", \"destreammain\", \"destreamtest\", \"bitcoinmain\", \"bitcointest\".");
builder.AppendLine("[options] Options for the CLI (optional) - e.g. -help, -rpcuser, see below."); builder.AppendLine("[options] Options for the CLI (optional) - e.g. -help, -rpcuser, see below.");
builder.AppendLine("[command] Name of RPC method or API <controller>/<method>."); builder.AppendLine("[command] Name of RPC method or API <controller>/<method>.");
builder.AppendLine("[arguments] Argument by position (RPC) or Name = Value pairs (API) (optional)."); builder.AppendLine("[arguments] Argument by position (RPC) or Name = Value pairs (API) (optional).");
...@@ -79,8 +79,8 @@ namespace DeStream.Bitcoin.Cli ...@@ -79,8 +79,8 @@ namespace DeStream.Bitcoin.Cli
builder.AppendLine(); builder.AppendLine();
builder.AppendLine("Examples:"); builder.AppendLine("Examples:");
builder.AppendLine(); builder.AppendLine();
builder.AppendLine("dotnet run stratis Wallet/history WalletName=testwallet - Lists all the historical transactions of the wallet called 'testwallet'."); builder.AppendLine("dotnet run destream Wallet/history WalletName=testwallet - Lists all the historical transactions of the wallet called 'testwallet'.");
builder.AppendLine("dotnet run stratis getinfo -rpcuser=stratistestuser -rpcpassword=stratistestpassword -rpcconnect=127.0.0.3 -rpcport=26174 - Displays general information about the DeStream node on the 127.0.0.3:26174, authenticating with the RPC specified user."); builder.AppendLine("dotnet run destream getinfo -rpcuser=destreamtestuser -rpcpassword=destreamtestpassword -rpcconnect=127.0.0.3 -rpcport=26174 - Displays general information about the DeStream node on the 127.0.0.3:26174, authenticating with the RPC specified user.");
builder.AppendLine("dotnet run bitcoin getbalance -rpcuser=btctestuser -rpcpassword=btctestpass - Displays the current balance of the opened wallet on the 127.0.0.1:8332 node, authenticating with the RPC specified user."); builder.AppendLine("dotnet run bitcoin getbalance -rpcuser=btctestuser -rpcpassword=btctestpass - Displays the current balance of the opened wallet on the 127.0.0.1:8332 node, authenticating with the RPC specified user.");
Console.WriteLine(builder); Console.WriteLine(builder);
return; return;
...@@ -90,7 +90,7 @@ namespace DeStream.Bitcoin.Cli ...@@ -90,7 +90,7 @@ namespace DeStream.Bitcoin.Cli
int defaultRestApiPort = 0; int defaultRestApiPort = 0;
Network network = null; Network network = null;
if (networkName.Contains("stratis")) if (networkName.Contains("destream"))
{ {
defaultRestApiPort = 37221; defaultRestApiPort = 37221;
network = Network.DeStreamMain; network = Network.DeStreamMain;
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"profiles": { "profiles": {
"DeStream.CLI DeStream REST API": { "DeStream.CLI DeStream REST API": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "stratis Wallet/files" "commandLineArgs": "destream Wallet/files"
}, },
"DeStream.CLI DeStream RPC": { "DeStream.CLI DeStream RPC": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "stratis -rpcuser=stratistestuser -rpcpassword=stratistestpass -rpcport=26174 getinfo" "commandLineArgs": "destream -rpcuser=destreamtestuser -rpcpassword=destreamtestpass -rpcport=26174 getinfo"
}, },
"DeStream.CLI Bitcoin RPC": { "DeStream.CLI Bitcoin RPC": {
"commandName": "Project", "commandName": "Project",
......
...@@ -70,7 +70,7 @@ namespace DeStream.Bitcoin.Features.Consensus ...@@ -70,7 +70,7 @@ namespace DeStream.Bitcoin.Features.Consensus
public class Checkpoints : ICheckpoints public class Checkpoints : ICheckpoints
{ {
/// <summary>List of selected checkpoints for STRAT mainnet.</summary> /// <summary>List of selected checkpoints for STRAT mainnet.</summary>
private static Dictionary<int, CheckpointInfo> stratisMainnetCheckpoints = new Dictionary<int, CheckpointInfo> private static Dictionary<int, CheckpointInfo> destreamMainnetCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 0, new CheckpointInfo(new uint256("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, { 0, new CheckpointInfo(new uint256("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) },
{ 2, new CheckpointInfo(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e")) }, // Premine { 2, new CheckpointInfo(new uint256("0xbca5936f638181e74a5f1e9999c95b0ce77da48c2688399e72bcc53a00c61eff"), new uint256("0x7d61c139a471821caa6b7635a4636e90afcfe5e195040aecbc1ad7d24924db1e")) }, // Premine
...@@ -92,7 +92,7 @@ namespace DeStream.Bitcoin.Features.Consensus ...@@ -92,7 +92,7 @@ namespace DeStream.Bitcoin.Features.Consensus
}; };
/// <summary>List of selected checkpoints for STRAT testnet.</summary> /// <summary>List of selected checkpoints for STRAT testnet.</summary>
private static Dictionary<int, CheckpointInfo> stratisTestnetCheckpoints = new Dictionary<int, CheckpointInfo> private static Dictionary<int, CheckpointInfo> destreamTestnetCheckpoints = new Dictionary<int, CheckpointInfo>
{ {
{ 0, new CheckpointInfo(new uint256("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) }, { 0, new CheckpointInfo(new uint256("0x00000e246d7b73b88c9ab55f2e5e94d9e22d471def3df5ea448f5576b1d156b9"), new uint256("0x0000000000000000000000000000000000000000000000000000000000000000")) },
{ 2, new CheckpointInfo(new uint256("0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"), new uint256("0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02")) }, { 2, new CheckpointInfo(new uint256("0x56959b1c8498631fb0ca5fe7bd83319dccdc6ac003dccb3171f39f553ecfa2f2"), new uint256("0x13f4c27ca813aefe2d9018077f8efeb3766796b9144fcc4cd51803bf4376ab02")) },
...@@ -147,7 +147,7 @@ namespace DeStream.Bitcoin.Features.Consensus ...@@ -147,7 +147,7 @@ namespace DeStream.Bitcoin.Features.Consensus
/// <summary> /// <summary>
/// Initializes a new instance of the object. /// Initializes a new instance of the object.
/// </summary> /// </summary>
/// <param name="network">Specification of the network the node runs on - regtest/testnet/mainnet/stratis test/main.</param> /// <param name="network">Specification of the network the node runs on - regtest/testnet/mainnet/destream test/main.</param>
/// <param name="settings">Consensus settings for node - used to see if checkpoints have been disabled or not.</param> /// <param name="settings">Consensus settings for node - used to see if checkpoints have been disabled or not.</param>
public Checkpoints(Network network, ConsensusSettings settings) public Checkpoints(Network network, ConsensusSettings settings)
{ {
...@@ -158,8 +158,8 @@ namespace DeStream.Bitcoin.Features.Consensus ...@@ -158,8 +158,8 @@ namespace DeStream.Bitcoin.Features.Consensus
else if (network.Equals(Network.Main)) this.checkpoints = bitcoinMainnetCheckpoints; else if (network.Equals(Network.Main)) this.checkpoints = bitcoinMainnetCheckpoints;
else if (network.Equals(Network.TestNet)) this.checkpoints = bitcoinTestnetCheckpoints; else if (network.Equals(Network.TestNet)) this.checkpoints = bitcoinTestnetCheckpoints;
else if (network.Equals(Network.RegTest)) this.checkpoints = new Dictionary<int, CheckpointInfo>(); else if (network.Equals(Network.RegTest)) this.checkpoints = new Dictionary<int, CheckpointInfo>();
else if (network.Equals(Network.DeStreamMain)) this.checkpoints = stratisMainnetCheckpoints; else if (network.Equals(Network.DeStreamMain)) this.checkpoints = destreamMainnetCheckpoints;
else if (network.Equals(Network.DeStreamTest)) this.checkpoints = stratisTestnetCheckpoints; else if (network.Equals(Network.DeStreamTest)) this.checkpoints = destreamTestnetCheckpoints;
else this.checkpoints = new Dictionary<int, CheckpointInfo>(); else this.checkpoints = new Dictionary<int, CheckpointInfo>();
} }
......
...@@ -33,7 +33,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -33,7 +33,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsIPAddressResourceRecord_AndIsIPv4_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsIPAddressResourceRecord_AndIsIPv4_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("192.168.0.1")); IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("192.168.0.1"));
Question question = new Question(domain, RecordType.A); Question question = new Question(domain, RecordType.A);
...@@ -56,7 +56,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -56,7 +56,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsIPAddressResourceRecord_AndIsIPv6_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsIPAddressResourceRecord_AndIsIPv6_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("2001:db8:85a3:0:0:8a2e:370:7334")); IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("2001:db8:85a3:0:0:8a2e:370:7334"));
Question question = new Question(domain, RecordType.AAAA); Question question = new Question(domain, RecordType.AAAA);
...@@ -79,8 +79,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -79,8 +79,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsCanonicalNameResourceRecord_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsCanonicalNameResourceRecord_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain cNameDomain = new Domain("www.stratis.test.com"); Domain cNameDomain = new Domain("www.destream.test.com");
CanonicalNameResourceRecord testResourceRecord = new CanonicalNameResourceRecord(domain, cNameDomain); CanonicalNameResourceRecord testResourceRecord = new CanonicalNameResourceRecord(domain, cNameDomain);
Question question = new Question(domain, RecordType.CNAME); Question question = new Question(domain, RecordType.CNAME);
...@@ -103,8 +103,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -103,8 +103,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsMailExchangeResourceRecord_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsMailExchangeResourceRecord_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain exchangeDomain = new Domain("mail.stratis.test.com"); Domain exchangeDomain = new Domain("mail.destream.test.com");
int preference = 10; int preference = 10;
MailExchangeResourceRecord testResourceRecord = new MailExchangeResourceRecord(domain, preference, exchangeDomain); MailExchangeResourceRecord testResourceRecord = new MailExchangeResourceRecord(domain, preference, exchangeDomain);
...@@ -130,7 +130,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -130,7 +130,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsNameServerResourceRecord_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsNameServerResourceRecord_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain nsDomain = new Domain("ns"); Domain nsDomain = new Domain("ns");
NameServerResourceRecord testResourceRecord = new NameServerResourceRecord(domain, nsDomain); NameServerResourceRecord testResourceRecord = new NameServerResourceRecord(domain, nsDomain);
...@@ -155,8 +155,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -155,8 +155,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsPointerResourceRecord_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsPointerResourceRecord_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain nsDomain = new Domain("pointer.stratis.test.com"); Domain nsDomain = new Domain("pointer.destream.test.com");
PointerResourceRecord testResourceRecord = new PointerResourceRecord(domain, nsDomain); PointerResourceRecord testResourceRecord = new PointerResourceRecord(domain, nsDomain);
...@@ -180,7 +180,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -180,7 +180,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenLoad_AndStreamContainsStartOfAuthorityResourceRecord_ThenEntryIsPopulated() public void WhenLoad_AndStreamContainsStartOfAuthorityResourceRecord_ThenEntryIsPopulated()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain masterDomain = new Domain("master.test.com"); Domain masterDomain = new Domain("master.test.com");
Domain responsibleDomain = new Domain("responsible.test.com"); Domain responsibleDomain = new Domain("responsible.test.com");
long serialNumber = 12121212; long serialNumber = 12121212;
...@@ -228,7 +228,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -228,7 +228,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
// Arrange. // Arrange.
using (MemoryStream stream = new MemoryStream()) using (MemoryStream stream = new MemoryStream())
{ {
string domainName = "stratis.test.com"; string domainName = "destream.test.com";
DnsSeedMasterFile masterFile = new DnsSeedMasterFile(); DnsSeedMasterFile masterFile = new DnsSeedMasterFile();
IList<IResourceRecord> testResourceRecords = new List<IResourceRecord>() IList<IResourceRecord> testResourceRecords = new List<IResourceRecord>()
...@@ -277,7 +277,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -277,7 +277,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsIPAddressResourceRecord_AndIsIPv4_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsIPAddressResourceRecord_AndIsIPv4_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("192.168.0.1")); IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("192.168.0.1"));
DnsSeedMasterFile masterFile = new DnsSeedMasterFile(); DnsSeedMasterFile masterFile = new DnsSeedMasterFile();
...@@ -307,7 +307,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -307,7 +307,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsIPAddressResourceRecord_AndIsIPv6_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsIPAddressResourceRecord_AndIsIPv6_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("2001:db8:85a3:0:0:8a2e:370:7334")); IPAddressResourceRecord testResourceRecord = new IPAddressResourceRecord(domain, IPAddress.Parse("2001:db8:85a3:0:0:8a2e:370:7334"));
DnsSeedMasterFile masterFile = new DnsSeedMasterFile(); DnsSeedMasterFile masterFile = new DnsSeedMasterFile();
...@@ -337,8 +337,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -337,8 +337,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsCanonicalNameResourceRecord_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsCanonicalNameResourceRecord_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain cNameDomain = new Domain("www.stratis.test.com"); Domain cNameDomain = new Domain("www.destream.test.com");
CanonicalNameResourceRecord testResourceRecord = new CanonicalNameResourceRecord(domain, cNameDomain); CanonicalNameResourceRecord testResourceRecord = new CanonicalNameResourceRecord(domain, cNameDomain);
DnsSeedMasterFile masterFile = new DnsSeedMasterFile(); DnsSeedMasterFile masterFile = new DnsSeedMasterFile();
...@@ -368,8 +368,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -368,8 +368,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsMailExchangeResourceRecord_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsMailExchangeResourceRecord_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain exchangeDomain = new Domain("mail.stratis.test.com"); Domain exchangeDomain = new Domain("mail.destream.test.com");
int preference = 10; int preference = 10;
MailExchangeResourceRecord testResourceRecord = new MailExchangeResourceRecord(domain, preference, exchangeDomain); MailExchangeResourceRecord testResourceRecord = new MailExchangeResourceRecord(domain, preference, exchangeDomain);
...@@ -400,7 +400,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -400,7 +400,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsNameServerResourceRecord_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsNameServerResourceRecord_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain nsDomain = new Domain("ns"); Domain nsDomain = new Domain("ns");
NameServerResourceRecord testResourceRecord = new NameServerResourceRecord(domain, nsDomain); NameServerResourceRecord testResourceRecord = new NameServerResourceRecord(domain, nsDomain);
...@@ -431,8 +431,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -431,8 +431,8 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsPointerResourceRecord_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsPointerResourceRecord_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain nsDomain = new Domain("pointer.stratis.test.com"); Domain nsDomain = new Domain("pointer.destream.test.com");
PointerResourceRecord testResourceRecord = new PointerResourceRecord(domain, nsDomain); PointerResourceRecord testResourceRecord = new PointerResourceRecord(domain, nsDomain);
DnsSeedMasterFile masterFile = new DnsSeedMasterFile(); DnsSeedMasterFile masterFile = new DnsSeedMasterFile();
...@@ -462,7 +462,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -462,7 +462,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsStartOfAuthorityResourceRecord_ThenEntryIsSaved() public void WhenSave_AndMasterListContainsStartOfAuthorityResourceRecord_ThenEntryIsSaved()
{ {
// Arrange // Arrange
Domain domain = new Domain("stratis.test.com"); Domain domain = new Domain("destream.test.com");
Domain masterDomain = new Domain("master.test.com"); Domain masterDomain = new Domain("master.test.com");
Domain responsibleDomain = new Domain("responsible.test.com"); Domain responsibleDomain = new Domain("responsible.test.com");
long serialNumber = 12121212; long serialNumber = 12121212;
...@@ -514,7 +514,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -514,7 +514,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
public void WhenSave_AndMasterListContainsEntries_ThenEntriesAreSaved() public void WhenSave_AndMasterListContainsEntries_ThenEntriesAreSaved()
{ {
// Arrange. // Arrange.
string domainName = "stratis.test.com"; string domainName = "destream.test.com";
IList<IResourceRecord> testResourceRecords = new List<IResourceRecord>() IList<IResourceRecord> testResourceRecords = new List<IResourceRecord>()
{ {
......
...@@ -86,7 +86,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -86,7 +86,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
IPeerAddressManager peerAddressManager = new Mock<IPeerAddressManager>().Object; IPeerAddressManager peerAddressManager = new Mock<IPeerAddressManager>().Object;
IDnsServer dnsServer = new Mock<IDnsServer>().Object; IDnsServer dnsServer = new Mock<IDnsServer>().Object;
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
Action a = () => { new WhitelistManager(dateTimeProvider, loggerFactory, peerAddressManager, dnsServer, null, dnsSettings); }; Action a = () => { new WhitelistManager(dateTimeProvider, loggerFactory, peerAddressManager, dnsServer, null, dnsSettings); };
...@@ -105,7 +105,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -105,7 +105,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
IDnsServer dnsServer = new Mock<IDnsServer>().Object; IDnsServer dnsServer = new Mock<IDnsServer>().Object;
NodeSettings nodeSettings = NodeSettings.Default(); NodeSettings nodeSettings = NodeSettings.Default();
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
Action a = () => { new WhitelistManager(dateTimeProvider, loggerFactory, peerAddressManager, dnsServer, null, dnsSettings); }; Action a = () => { new WhitelistManager(dateTimeProvider, loggerFactory, peerAddressManager, dnsServer, null, dnsSettings); };
...@@ -169,7 +169,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -169,7 +169,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
NodeSettings nodeSettings = NodeSettings.Default(); NodeSettings nodeSettings = NodeSettings.Default();
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod; dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings(); ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings();
connectionSettings.Load(nodeSettings); connectionSettings.Load(nodeSettings);
...@@ -273,7 +273,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -273,7 +273,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
NodeSettings nodeSettings = new NodeSettings(network, args:args); NodeSettings nodeSettings = new NodeSettings(network, args:args);
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod; dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
dnsSettings.DnsFullNode = false; dnsSettings.DnsFullNode = false;
ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings(); ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings();
connectionSettings.Load(nodeSettings); connectionSettings.Load(nodeSettings);
...@@ -362,7 +362,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -362,7 +362,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsFullNode = true; dnsSettings.DnsFullNode = true;
dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod; dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings(); ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings();
connectionSettings.Load(nodeSettings); connectionSettings.Load(nodeSettings);
...@@ -454,7 +454,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests ...@@ -454,7 +454,7 @@ namespace DeStream.Bitcoin.Features.Dns.Tests
NodeSettings nodeSettings = NodeSettings.Default(); NodeSettings nodeSettings = NodeSettings.Default();
DnsSettings dnsSettings = new Mock<DnsSettings>().Object; DnsSettings dnsSettings = new Mock<DnsSettings>().Object;
dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod; dnsSettings.DnsPeerBlacklistThresholdInSeconds = inactiveTimePeriod;
dnsSettings.DnsHostName = "stratis.test.com"; dnsSettings.DnsHostName = "destream.test.com";
ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings(); ConnectionManagerSettings connectionSettings = new ConnectionManagerSettings();
connectionSettings.Load(nodeSettings); connectionSettings.Load(nodeSettings);
......
...@@ -12,7 +12,7 @@ To install and run the DNS Server, you need ...@@ -12,7 +12,7 @@ To install and run the DNS Server, you need
### Get the repository and its dependencies ### Get the repository and its dependencies
``` ```
git clone https://github.com/stratisproject/DeStreamBitcoinFullNode.git git clone https://github.com/DeStream-dev/destream-blockchain.git
cd DeStreamBitcoinFullNode cd DeStreamBitcoinFullNode
git submodule update --init --recursive git submodule update --init --recursive
``` ```
...@@ -23,25 +23,25 @@ With this node, you can run the DNS Server in isolation or as a DeStream node wi ...@@ -23,25 +23,25 @@ With this node, you can run the DNS Server in isolation or as a DeStream node wi
1. To run a <b>DeStream</b> node <b>only</b> on <b>MainNet</b>, do 1. To run a <b>DeStream</b> node <b>only</b> on <b>MainNet</b>, do
``` ```
cd DeStream.DeStreamDnsD cd DeStream.DeStreamDnsD
dotnet run -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com dotnet run -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com
``` ```
2. To run a <b>DeStream</b> node and <b>full node</b> on <b>MainNet</b>, do 2. To run a <b>DeStream</b> node and <b>full node</b> on <b>MainNet</b>, do
``` ```
cd DeStream.DeStreamDnsD cd DeStream.DeStreamDnsD
dotnet run -dnsfullnode -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com dotnet run -dnsfullnode -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com
``` ```
3. To run a <b>DeStream</b> node <b>only</b> on <b>TestNet</b>, do 3. To run a <b>DeStream</b> node <b>only</b> on <b>TestNet</b>, do
``` ```
cd DeStream.DeStreamDnsD cd DeStream.DeStreamDnsD
dotnet run -testnet -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com dotnet run -testnet -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com
``` ```
4. To run a <b>DeStream</b> node and <b>full node</b> on <b>TestNet</b>, do 4. To run a <b>DeStream</b> node and <b>full node</b> on <b>TestNet</b>, do
``` ```
cd DeStream.DeStreamDnsD cd DeStream.DeStreamDnsD
dotnet run -testnet -dnsfullnode -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com dotnet run -testnet -dnsfullnode -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com
``` ```
### Command-line arguments ### Command-line arguments
...@@ -60,22 +60,22 @@ Given the following settings for the DeStream DNS Server: ...@@ -60,22 +60,22 @@ Given the following settings for the DeStream DNS Server:
| Argument | Value | | Argument | Value |
| ------------- | --------------------------------- | | ------------- | --------------------------------- |
| dnslistenport | 53 | | dnslistenport | 53 |
| dnshostname | stratisdns.stratisplatform.com | | dnshostname | destreamdns.destreamplatform.com |
| dnsnameserver | ns.stratisdns.stratisplatform.com | | dnsnameserver | ns.destreamdns.destreamplatform.com |
You should have NS and A record in your ISP DNS records for your DNS host domain: You should have NS and A record in your ISP DNS records for your DNS host domain:
| Type | Hostname | Data | | Type | Hostname | Data |
| -------- | --------------------------------- | --------------------------------- | | -------- | --------------------------------- | --------------------------------- |
| NS | stratisdns.stratisplatform.com | ns.stratisdns.stratisplatform.com | | NS | destreamdns.destreamplatform.com | ns.destreamdns.destreamplatform.com |
| A | ns.stratisdns.stratisplatform.com | 192.168.1.2 | | A | ns.destreamdns.destreamplatform.com | 192.168.1.2 |
To verify the DeStream DNS Server is running with these settings run: To verify the DeStream DNS Server is running with these settings run:
``` ```
dig +qr -p 53 stratisdns.stratisplatform.com dig +qr -p 53 destreamdns.destreamplatform.com
``` ```
or or
``` ```
nslookup stratisdns.stratisplatform.com nslookup destreamdns.destreamplatform.com
``` ```
...@@ -6,9 +6,8 @@ using DeStream.Bitcoin.Features.Wallet.Interfaces; ...@@ -6,9 +6,8 @@ using DeStream.Bitcoin.Features.Wallet.Interfaces;
namespace DeStream.Bitcoin.Features.LightWallet namespace DeStream.Bitcoin.Features.LightWallet
{ {
/// <summary> /// <summary>
/// Light wallet fixed fee policy used for stratis network. /// Light wallet fixed fee policy used for destream network.
/// </summary> /// </summary>
/// <seealso cref="https://github.com/stratisproject/stratisX/blob/master/src/wallet.cpp#L1437">DeStreamX fee calculation.</seealso>
public class LightWalletFixedFeePolicy : IWalletFeePolicy public class LightWalletFixedFeePolicy : IWalletFeePolicy
{ {
/// <inheritdoc /> /// <inheritdoc />
......
...@@ -39,7 +39,6 @@ namespace DeStream.Bitcoin.Features.Miner.Interfaces ...@@ -39,7 +39,6 @@ namespace DeStream.Bitcoin.Features.Miner.Interfaces
/// <returns>Staking difficulty.</returns> /// <returns>Staking difficulty.</returns>
/// <remarks> /// <remarks>
/// The actual idea behind the calculation is a mystery. It was simply ported from /// The actual idea behind the calculation is a mystery. It was simply ported from
/// <see cref="https://github.com/stratisproject/stratisX/blob/47851b7337f528f52ec20e86dca7dcead8191cf5/src/rpcblockchain.cpp#L16"/>.
/// </remarks> /// </remarks>
double GetDifficulty(ChainedBlock block); double GetDifficulty(ChainedBlock block);
...@@ -68,7 +67,6 @@ namespace DeStream.Bitcoin.Features.Miner.Interfaces ...@@ -68,7 +67,6 @@ namespace DeStream.Bitcoin.Features.Miner.Interfaces
/// presented on the network to generate each block. /// presented on the network to generate each block.
/// <para> /// <para>
/// The method was ported from /// The method was ported from
/// <see cref="https://github.com/stratisproject/stratisX/blob/47851b7337f528f52ec20e86dca7dcead8191cf5/src/rpcblockchain.cpp#L74"/>.
/// </para> /// </para>
/// </remarks> /// </remarks>
double GetNetworkWeight(); double GetNetworkWeight();
......
...@@ -181,7 +181,6 @@ namespace DeStream.Bitcoin.Features.Miner ...@@ -181,7 +181,6 @@ namespace DeStream.Bitcoin.Features.Miner
/// <summary><c>true</c> if coinstake transaction splits the coin and generates extra UTXO /// <summary><c>true</c> if coinstake transaction splits the coin and generates extra UTXO
/// to prevent halting chain; <c>false</c> to disable coinstake splitting.</summary> /// to prevent halting chain; <c>false</c> to disable coinstake splitting.</summary>
/// <remarks>TODO: It should be configurable option, not constant. <see cref="https://github.com/stratisproject/DeStreamBitcoinFullNode/issues/550"/></remarks>
public const bool CoinstakeSplitEnabled = true; public const bool CoinstakeSplitEnabled = true;
/// <summary> If <see cref="CoinstakeSplitEnabled"/> is set, the coinstake will be split if /// <summary> If <see cref="CoinstakeSplitEnabled"/> is set, the coinstake will be split if
......
...@@ -615,7 +615,7 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests ...@@ -615,7 +615,7 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests
string walletFileExtension = "wallet.json"; string walletFileExtension = "wallet.json";
string testWalletFileName = Path.ChangeExtension("myWallet", walletFileExtension); string testWalletFileName = Path.ChangeExtension("myWallet", walletFileExtension);
string testWalletPath = Path.Combine(AppContext.BaseDirectory, "stratisnode", testWalletFileName); string testWalletPath = Path.Combine(AppContext.BaseDirectory, "destreamnode", testWalletFileName);
string folder = Path.GetDirectoryName(testWalletPath); string folder = Path.GetDirectoryName(testWalletPath);
string[] files = new string[] { testWalletFileName }; string[] files = new string[] { testWalletFileName };
mockWalletWrapper.Setup(w => w.GetWalletsFiles()).Returns((folder, files)); mockWalletWrapper.Setup(w => w.GetWalletsFiles()).Returns((folder, files));
......
...@@ -35,9 +35,9 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests ...@@ -35,9 +35,9 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests
public void GetAllTransactionsByCoinTypeReturnsTransactionsFromWalletByCoinType() public void GetAllTransactionsByCoinTypeReturnsTransactionsFromWalletByCoinType()
{ {
var wallet = new Wallet(); var wallet = new Wallet();
var stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount", CoinType.DeStream); var destreamAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount", CoinType.DeStream);
var bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); var bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin);
var stratisAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount2", CoinType.DeStream); var destreamAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount2", CoinType.DeStream);
var transaction1 = CreateTransaction(new uint256(1), new Money(15000), 1); var transaction1 = CreateTransaction(new uint256(1), new Money(15000), 1);
var transaction2 = CreateTransaction(new uint256(2), new Money(91209), 1); var transaction2 = CreateTransaction(new uint256(2), new Money(91209), 1);
...@@ -46,16 +46,16 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests ...@@ -46,16 +46,16 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests
var transaction5 = CreateTransaction(new uint256(5), new Money(52387), 1); var transaction5 = CreateTransaction(new uint256(5), new Money(52387), 1);
var transaction6 = CreateTransaction(new uint256(6), new Money(879873), 1); var transaction6 = CreateTransaction(new uint256(6), new Money(879873), 1);
stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction1); destreamAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction1);
stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction2); destreamAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction2);
bitcoinAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction3); bitcoinAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction3);
bitcoinAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction4); bitcoinAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction4);
stratisAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction5); destreamAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction5);
stratisAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction6); destreamAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction6);
wallet.AccountsRoot.Add(stratisAccountRoot); wallet.AccountsRoot.Add(destreamAccountRoot);
wallet.AccountsRoot.Add(bitcoinAccountRoot); wallet.AccountsRoot.Add(bitcoinAccountRoot);
wallet.AccountsRoot.Add(stratisAccountRoot2); wallet.AccountsRoot.Add(destreamAccountRoot2);
var result = wallet.GetAllTransactionsByCoinType(CoinType.DeStream).ToList(); var result = wallet.GetAllTransactionsByCoinType(CoinType.DeStream).ToList();
...@@ -99,20 +99,20 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests ...@@ -99,20 +99,20 @@ namespace DeStream.Bitcoin.Features.Wallet.Tests
public void GetAllPubKeysByCoinTypeReturnsPubkeysFromWalletByCoinType() public void GetAllPubKeysByCoinTypeReturnsPubkeysFromWalletByCoinType()
{ {
var wallet = new Wallet(); var wallet = new Wallet();
var stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount", CoinType.DeStream); var destreamAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount", CoinType.DeStream);
var bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); var bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin);
var stratisAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount2", CoinType.DeStream); var destreamAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("DeStreamAccount2", CoinType.DeStream);
wallet.AccountsRoot.Add(stratisAccountRoot); wallet.AccountsRoot.Add(destreamAccountRoot);
wallet.AccountsRoot.Add(bitcoinAccountRoot); wallet.AccountsRoot.Add(bitcoinAccountRoot);
wallet.AccountsRoot.Add(stratisAccountRoot2); wallet.AccountsRoot.Add(destreamAccountRoot2);
var result = wallet.GetAllPubKeysByCoinType(CoinType.DeStream).ToList(); var result = wallet.GetAllPubKeysByCoinType(CoinType.DeStream).ToList();
Assert.Equal(4, result.Count); Assert.Equal(4, result.Count);
Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[0]); Assert.Equal(destreamAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[0]);
Assert.Equal(stratisAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[1]); Assert.Equal(destreamAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[1]);
Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[2]); Assert.Equal(destreamAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[2]);
Assert.Equal(stratisAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[3]); Assert.Equal(destreamAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[3]);
} }
[Fact] [Fact]
......
...@@ -12,7 +12,6 @@ namespace DeStream.Bitcoin.Features.Wallet.Helpers ...@@ -12,7 +12,6 @@ namespace DeStream.Bitcoin.Features.Wallet.Helpers
/// This specific comparer has been made to filter out duplicate payment listings in the case of a transaction with multiple inputs. /// This specific comparer has been made to filter out duplicate payment listings in the case of a transaction with multiple inputs.
/// This causes multiple items inside the wallet data that all have the same amount, transaction/spending id and payment details. /// This causes multiple items inside the wallet data that all have the same amount, transaction/spending id and payment details.
/// However not all fields on this model are equal to each other so we only compare the ones we need. /// However not all fields on this model are equal to each other so we only compare the ones we need.
/// See: https://github.com/stratisproject/Breeze/issues/175
/// </remarks> /// </remarks>
public class SentTransactionItemModelComparer : IEqualityComparer<TransactionItemModel> public class SentTransactionItemModelComparer : IEqualityComparer<TransactionItemModel>
{ {
......
...@@ -65,7 +65,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -65,7 +65,7 @@ namespace DeStream.Bitcoin.IntegrationTests
try try
{ {
var fullNode = this.apiTestsFixture.stratisPowNode.FullNode; var fullNode = this.apiTestsFixture.destreamPowNode.FullNode;
var apiURI = fullNode.NodeService<ApiSettings>().ApiUri; var apiURI = fullNode.NodeService<ApiSettings>().ApiUri;
using (client = new HttpClient()) using (client = new HttpClient())
...@@ -91,7 +91,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -91,7 +91,7 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
try try
{ {
var fullNode = this.apiTestsFixture.stratisStakeNode.FullNode; var fullNode = this.apiTestsFixture.destreamStakeNode.FullNode;
var apiURI = fullNode.NodeService<ApiSettings>().ApiUri; var apiURI = fullNode.NodeService<ApiSettings>().ApiUri;
Assert.NotNull(fullNode.NodeService<IPosMinting>(true)); Assert.NotNull(fullNode.NodeService<IPosMinting>(true));
...@@ -134,7 +134,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -134,7 +134,7 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
try try
{ {
var fullNode = this.apiTestsFixture.stratisPowNode.FullNode; var fullNode = this.apiTestsFixture.destreamPowNode.FullNode;
var apiURI = fullNode.NodeService<ApiSettings>().ApiUri; var apiURI = fullNode.NodeService<ApiSettings>().ApiUri;
using (client = new HttpClient()) using (client = new HttpClient())
...@@ -162,7 +162,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -162,7 +162,7 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
try try
{ {
var fullNode = this.apiTestsFixture.stratisPowNode.FullNode; var fullNode = this.apiTestsFixture.destreamPowNode.FullNode;
var apiURI = fullNode.NodeService<ApiSettings>().ApiUri; var apiURI = fullNode.NodeService<ApiSettings>().ApiUri;
using (client = new HttpClient()) using (client = new HttpClient())
...@@ -186,8 +186,8 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -186,8 +186,8 @@ namespace DeStream.Bitcoin.IntegrationTests
public class ApiTestsFixture : IDisposable public class ApiTestsFixture : IDisposable
{ {
public NodeBuilder builder; public NodeBuilder builder;
public CoreNode stratisPowNode; public CoreNode destreamPowNode;
public CoreNode stratisStakeNode; public CoreNode destreamStakeNode;
private bool initialBlockSignature; private bool initialBlockSignature;
public ApiTestsFixture() public ApiTestsFixture()
...@@ -197,7 +197,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -197,7 +197,7 @@ namespace DeStream.Bitcoin.IntegrationTests
this.builder = NodeBuilder.Create(); this.builder = NodeBuilder.Create();
this.stratisPowNode = this.builder.CreateDeStreamPowNode(false, fullNodeBuilder => this.destreamPowNode = this.builder.CreateDeStreamPowNode(false, fullNodeBuilder =>
{ {
fullNodeBuilder fullNodeBuilder
.UsePowConsensus() .UsePowConsensus()
...@@ -210,17 +210,17 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -210,17 +210,17 @@ namespace DeStream.Bitcoin.IntegrationTests
}); });
// start api on different ports // start api on different ports
this.stratisPowNode.ConfigParameters.Add("apiuri", "http://localhost:37221"); this.destreamPowNode.ConfigParameters.Add("apiuri", "http://localhost:37221");
this.builder.StartAll(); this.builder.StartAll();
// Move a wallet file to the right folder and restart the wallet manager to take it into account. // Move a wallet file to the right folder and restart the wallet manager to take it into account.
this.InitializeTestWallet(this.stratisPowNode.FullNode.DataFolder.WalletPath); this.InitializeTestWallet(this.destreamPowNode.FullNode.DataFolder.WalletPath);
var walletManager = this.stratisPowNode.FullNode.NodeService<IWalletManager>() as WalletManager; var walletManager = this.destreamPowNode.FullNode.NodeService<IWalletManager>() as WalletManager;
walletManager.Start(); walletManager.Start();
Block.BlockSignature = true; Block.BlockSignature = true;
this.stratisStakeNode = this.builder.CreateDeStreamPosNode(false, fullNodeBuilder => this.destreamStakeNode = this.builder.CreateDeStreamPosNode(false, fullNodeBuilder =>
{ {
fullNodeBuilder fullNodeBuilder
.UsePosConsensus() .UsePosConsensus()
...@@ -232,7 +232,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -232,7 +232,7 @@ namespace DeStream.Bitcoin.IntegrationTests
.AddRPC(); .AddRPC();
}); });
this.stratisStakeNode.ConfigParameters.Add("apiuri", "http://localhost:37222"); this.destreamStakeNode.ConfigParameters.Add("apiuri", "http://localhost:37222");
this.builder.StartAll(); this.builder.StartAll();
} }
......
...@@ -8,7 +8,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore ...@@ -8,7 +8,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore
[Fact] [Fact]
public void Attempt_to_spend_coin_earned_through_proof_of_work_BEFORE_coin_maturity_will_fail() public void Attempt_to_spend_coin_earned_through_proof_of_work_BEFORE_coin_maturity_will_fail()
{ {
Given(a_sending_and_receiving_stratis_bitcoin_node_and_wallet); Given(a_sending_and_receiving_destream_bitcoin_node_and_wallet);
And(a_block_is_mined_creating_spendable_coins); And(a_block_is_mined_creating_spendable_coins);
And(more_blocks_mined_to_just_BEFORE_maturity_of_original_block); And(more_blocks_mined_to_just_BEFORE_maturity_of_original_block);
When(spending_the_coins_from_original_block); When(spending_the_coins_from_original_block);
...@@ -18,7 +18,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore ...@@ -18,7 +18,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore
[Fact] [Fact]
public void Attempt_to_spend_coin_earned_through_proof_of_work_AFTER_maturity_will_succeed() public void Attempt_to_spend_coin_earned_through_proof_of_work_AFTER_maturity_will_succeed()
{ {
Given(a_sending_and_receiving_stratis_bitcoin_node_and_wallet); Given(a_sending_and_receiving_destream_bitcoin_node_and_wallet);
And(a_block_is_mined_creating_spendable_coins); And(a_block_is_mined_creating_spendable_coins);
And(more_blocks_mined_to_just_AFTER_maturity_of_original_block); And(more_blocks_mined_to_just_AFTER_maturity_of_original_block);
When(spending_the_coins_from_original_block); When(spending_the_coins_from_original_block);
......
...@@ -40,7 +40,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore ...@@ -40,7 +40,7 @@ namespace DeStream.Bitcoin.IntegrationTests.BlockStore
this.nodeBuilder.Dispose(); this.nodeBuilder.Dispose();
} }
private void a_sending_and_receiving_stratis_bitcoin_node_and_wallet() private void a_sending_and_receiving_destream_bitcoin_node_and_wallet()
{ {
this.sendingDeStreamBitcoinNode = this.nodeBuilder.CreateDeStreamPowNode(); this.sendingDeStreamBitcoinNode = this.nodeBuilder.CreateDeStreamPowNode();
this.receivingDeStreamBitcoinNode = this.nodeBuilder.CreateDeStreamPowNode(); this.receivingDeStreamBitcoinNode = this.nodeBuilder.CreateDeStreamPowNode();
......
...@@ -148,40 +148,40 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -148,40 +148,40 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
var stratisNode1 = builder.CreateDeStreamPowNode(); var destreamNode1 = builder.CreateDeStreamPowNode();
var stratisNode2 = builder.CreateDeStreamPowNode(); var destreamNode2 = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNode1.NotInIBD(); destreamNode1.NotInIBD();
stratisNode2.NotInIBD(); destreamNode2.NotInIBD();
// generate blocks and wait for the downloader to pickup // generate blocks and wait for the downloader to pickup
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStreamWithMiner(10); // coinbase maturity = 10 destreamNodeSync.GenerateDeStreamWithMiner(10); // coinbase maturity = 10
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ChainBehaviorState.ConsensusTip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ChainBehaviorState.ConsensusTip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
// sync both nodes // sync both nodes
stratisNode1.CreateRPCClient().AddNode(stratisNodeSync.Endpoint, true); destreamNode1.CreateRPCClient().AddNode(destreamNodeSync.Endpoint, true);
stratisNode2.CreateRPCClient().AddNode(stratisNodeSync.Endpoint, true); destreamNode2.CreateRPCClient().AddNode(destreamNodeSync.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode1.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode1.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
TestHelper.WaitLoop(() => stratisNode2.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode2.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
// set node2 to use inv (not headers) // set node2 to use inv (not headers)
stratisNode2.FullNode.ConnectionManager.ConnectedPeers.First().Behavior<BlockStoreBehavior>().PreferHeaders = false; destreamNode2.FullNode.ConnectionManager.ConnectedPeers.First().Behavior<BlockStoreBehavior>().PreferHeaders = false;
// generate two new blocks // generate two new blocks
stratisNodeSync.GenerateDeStreamWithMiner(2); destreamNodeSync.GenerateDeStreamWithMiner(2);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.Chain.Tip.HashBlock == stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.Chain.Tip.HashBlock == destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.CreateRPCClient().GetBestBlockHash()).Result != null); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.CreateRPCClient().GetBestBlockHash()).Result != null);
// wait for the other nodes to pick up the newly generated blocks // wait for the other nodes to pick up the newly generated blocks
TestHelper.WaitLoop(() => stratisNode1.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode1.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
TestHelper.WaitLoop(() => stratisNode2.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode2.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
} }
} }
...@@ -190,30 +190,30 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -190,30 +190,30 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
// generate blocks and wait for the downloader to pickup // generate blocks and wait for the downloader to pickup
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStreamWithMiner(10); destreamNodeSync.GenerateDeStreamWithMiner(10);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisNodeSync)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamNodeSync));
// set the tip of best chain some blocks in the apst // set the tip of best chain some blocks in the apst
stratisNodeSync.FullNode.Chain.SetTip(stratisNodeSync.FullNode.Chain.GetBlock(stratisNodeSync.FullNode.Chain.Height - 5)); destreamNodeSync.FullNode.Chain.SetTip(destreamNodeSync.FullNode.Chain.GetBlock(destreamNodeSync.FullNode.Chain.Height - 5));
// stop the node it will persist the chain with the reset tip // stop the node it will persist the chain with the reset tip
stratisNodeSync.FullNode.Dispose(); destreamNodeSync.FullNode.Dispose();
var newNodeInstance = builder.CloneDeStreamNode(stratisNodeSync); var newNodeInstance = builder.CloneDeStreamNode(destreamNodeSync);
// load the node, this should hit the block store recover code // load the node, this should hit the block store recover code
newNodeInstance.Start(); newNodeInstance.Start();
// check that store recovered to be the same as the best chain. // check that store recovered to be the same as the best chain.
Assert.Equal(newNodeInstance.FullNode.Chain.Tip.HashBlock, newNodeInstance.FullNode.HighestPersistedBlock().HashBlock); Assert.Equal(newNodeInstance.FullNode.Chain.Tip.HashBlock, newNodeInstance.FullNode.HighestPersistedBlock().HashBlock);
//TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisNodeSync)); //TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamNodeSync));
} }
} }
...@@ -222,51 +222,51 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -222,51 +222,51 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
var stratisNode1 = builder.CreateDeStreamPowNode(); var destreamNode1 = builder.CreateDeStreamPowNode();
var stratisNode2 = builder.CreateDeStreamPowNode(); var destreamNode2 = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNode1.NotInIBD(); destreamNode1.NotInIBD();
stratisNode2.NotInIBD(); destreamNode2.NotInIBD();
// generate blocks and wait for the downloader to pickup // generate blocks and wait for the downloader to pickup
stratisNode1.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNode1.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNode2.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNode2.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
// sync both nodes // sync both nodes
stratisNodeSync.CreateRPCClient().AddNode(stratisNode1.Endpoint, true); destreamNodeSync.CreateRPCClient().AddNode(destreamNode1.Endpoint, true);
stratisNodeSync.CreateRPCClient().AddNode(stratisNode2.Endpoint, true); destreamNodeSync.CreateRPCClient().AddNode(destreamNode2.Endpoint, true);
stratisNode1.GenerateDeStreamWithMiner(10); destreamNode1.GenerateDeStreamWithMiner(10);
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().Height == 10); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().Height == 10);
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock);
TestHelper.WaitLoop(() => stratisNode2.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock); TestHelper.WaitLoop(() => destreamNode2.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock);
// remove node 2 // remove node 2
stratisNodeSync.CreateRPCClient().RemoveNode(stratisNode2.Endpoint); destreamNodeSync.CreateRPCClient().RemoveNode(destreamNode2.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisNode2)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamNode2));
// mine some more with node 1 // mine some more with node 1
stratisNode1.GenerateDeStreamWithMiner(10); destreamNode1.GenerateDeStreamWithMiner(10);
// wait for node 1 to sync // wait for node 1 to sync
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().Height == 20); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().Height == 20);
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock);
// remove node 1 // remove node 1
stratisNodeSync.CreateRPCClient().RemoveNode(stratisNode1.Endpoint); destreamNodeSync.CreateRPCClient().RemoveNode(destreamNode1.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisNode1)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamNode1));
// mine a higher chain with node2 // mine a higher chain with node2
stratisNode2.GenerateDeStreamWithMiner(20); destreamNode2.GenerateDeStreamWithMiner(20);
TestHelper.WaitLoop(() => stratisNode2.FullNode.HighestPersistedBlock().Height == 30); TestHelper.WaitLoop(() => destreamNode2.FullNode.HighestPersistedBlock().Height == 30);
// add node2 // add node2
stratisNodeSync.CreateRPCClient().AddNode(stratisNode2.Endpoint, true); destreamNodeSync.CreateRPCClient().AddNode(destreamNode2.Endpoint, true);
// node2 should be synced // node2 should be synced
TestHelper.WaitLoop(() => stratisNode2.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock); TestHelper.WaitLoop(() => destreamNode2.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock);
} }
} }
...@@ -275,26 +275,26 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -275,26 +275,26 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode1 = builder.CreateDeStreamPowNode(); var destreamNode1 = builder.CreateDeStreamPowNode();
var stratisNode2 = builder.CreateDeStreamPowNode(); var destreamNode2 = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNode1.NotInIBD(); destreamNode1.NotInIBD();
stratisNode2.NotInIBD(); destreamNode2.NotInIBD();
// generate blocks and wait for the downloader to pickup // generate blocks and wait for the downloader to pickup
stratisNode1.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNode1.FullNode.Network)); destreamNode1.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNode1.FullNode.Network));
stratisNode2.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNode2.FullNode.Network)); destreamNode2.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNode2.FullNode.Network));
// sync both nodes // sync both nodes
stratisNode1.CreateRPCClient().AddNode(stratisNode2.Endpoint, true); destreamNode1.CreateRPCClient().AddNode(destreamNode2.Endpoint, true);
stratisNode1.GenerateDeStreamWithMiner(10); destreamNode1.GenerateDeStreamWithMiner(10);
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().Height == 10); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().Height == 10);
TestHelper.WaitLoop(() => stratisNode1.FullNode.HighestPersistedBlock().HashBlock == stratisNode2.FullNode.HighestPersistedBlock().HashBlock); TestHelper.WaitLoop(() => destreamNode1.FullNode.HighestPersistedBlock().HashBlock == destreamNode2.FullNode.HighestPersistedBlock().HashBlock);
var bestBlock1 = stratisNode1.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNode1.FullNode.Chain.Tip.HashBlock).Result; var bestBlock1 = destreamNode1.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNode1.FullNode.Chain.Tip.HashBlock).Result;
Assert.NotNull(bestBlock1); Assert.NotNull(bestBlock1);
// get the block coinbase trx // get the block coinbase trx
var trx = stratisNode2.FullNode.BlockStoreManager().BlockRepository.GetTrxAsync(bestBlock1.Transactions.First().GetHash()).Result; var trx = destreamNode2.FullNode.BlockStoreManager().BlockRepository.GetTrxAsync(bestBlock1.Transactions.First().GetHash()).Result;
Assert.NotNull(trx); Assert.NotNull(trx);
Assert.Equal(bestBlock1.Transactions.First().GetHash(), trx.GetHash()); Assert.Equal(bestBlock1.Transactions.First().GetHash(), trx.GetHash());
} }
......
...@@ -172,38 +172,38 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -172,38 +172,38 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode = builder.CreateDeStreamPowNode(); var destreamNode = builder.CreateDeStreamPowNode();
var coreNode1 = builder.CreateNode(); var coreNode1 = builder.CreateNode();
var coreNode2 = builder.CreateNode(); var coreNode2 = builder.CreateNode();
builder.StartAll(); builder.StartAll();
//Core1 discovers 10 blocks, sends to stratis //Core1 discovers 10 blocks, sends to destream
var tip = coreNode1.FindBlock(10).Last(); var tip = coreNode1.FindBlock(10).Last();
stratisNode.CreateRPCClient().AddNode(coreNode1.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreNode1.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode1.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode1.CreateRPCClient().GetBestBlockHash());
stratisNode.CreateRPCClient().RemoveNode(coreNode1.Endpoint); destreamNode.CreateRPCClient().RemoveNode(coreNode1.Endpoint);
//Core2 discovers 20 blocks, sends to stratis //Core2 discovers 20 blocks, sends to destream
tip = coreNode2.FindBlock(20).Last(); tip = coreNode2.FindBlock(20).Last();
stratisNode.CreateRPCClient().AddNode(coreNode2.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreNode2.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash());
stratisNode.CreateRPCClient().RemoveNode(coreNode2.Endpoint); destreamNode.CreateRPCClient().RemoveNode(coreNode2.Endpoint);
((CachedCoinView)stratisNode.FullNode.CoinView()).FlushAsync().Wait(); ((CachedCoinView)destreamNode.FullNode.CoinView()).FlushAsync().Wait();
//Core1 discovers 30 blocks, sends to stratis //Core1 discovers 30 blocks, sends to destream
tip = coreNode1.FindBlock(30).Last(); tip = coreNode1.FindBlock(30).Last();
stratisNode.CreateRPCClient().AddNode(coreNode1.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreNode1.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode1.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode1.CreateRPCClient().GetBestBlockHash());
stratisNode.CreateRPCClient().RemoveNode(coreNode1.Endpoint); destreamNode.CreateRPCClient().RemoveNode(coreNode1.Endpoint);
//Core2 discovers 50 blocks, sends to stratis //Core2 discovers 50 blocks, sends to destream
tip = coreNode2.FindBlock(50).Last(); tip = coreNode2.FindBlock(50).Last();
stratisNode.CreateRPCClient().AddNode(coreNode2.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreNode2.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash());
stratisNode.CreateRPCClient().RemoveNode(coreNode2.Endpoint); destreamNode.CreateRPCClient().RemoveNode(coreNode2.Endpoint);
((CachedCoinView)stratisNode.FullNode.CoinView()).FlushAsync().Wait(); ((CachedCoinView)destreamNode.FullNode.CoinView()).FlushAsync().Wait();
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode2.CreateRPCClient().GetBestBlockHash());
} }
} }
......
...@@ -73,7 +73,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers ...@@ -73,7 +73,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers
this.networkPeerFactory = new NetworkPeerFactory(network, DateTimeProvider.Default, loggerFactory, new PayloadProvider().DiscoverPayloads(), new SelfEndpointTracker()); this.networkPeerFactory = new NetworkPeerFactory(network, DateTimeProvider.Default, loggerFactory, new PayloadProvider().DiscoverPayloads(), new SelfEndpointTracker());
} }
/// <summary>Get stratis full node if possible.</summary> /// <summary>Get destream full node if possible.</summary>
public FullNode FullNode public FullNode FullNode
{ {
get get
......
...@@ -245,7 +245,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers ...@@ -245,7 +245,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers
public CoreNode CreateDeStreamPosNode(bool start = false, Action<IFullNodeBuilder> callback = null) public CoreNode CreateDeStreamPosNode(bool start = false, Action<IFullNodeBuilder> callback = null)
{ {
string child = this.CreateNewEmptyFolder(); string child = this.CreateNewEmptyFolder();
var node = new CoreNode(child, new DeStreamBitcoinPosRunner(callback), this, Network.RegTest, configfile: "stratis.conf"); var node = new CoreNode(child, new DeStreamBitcoinPosRunner(callback), this, Network.RegTest, configfile: "destream.conf");
this.Nodes.Add(node); this.Nodes.Add(node);
if (start) if (start)
node.Start(); node.Start();
......
...@@ -71,7 +71,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers ...@@ -71,7 +71,7 @@ namespace DeStream.Bitcoin.IntegrationTests.EnvironmentMockUpHelpers
public void Start(string dataDir) public void Start(string dataDir)
{ {
NodeSettings nodeSettings = new NodeSettings(Network.DeStreamRegTest, ProtocolVersion.ALT_PROTOCOL_VERSION, args:new string[] { "-conf=stratis.conf", "-datadir=" + dataDir }, loadConfiguration:false); NodeSettings nodeSettings = new NodeSettings(Network.DeStreamRegTest, ProtocolVersion.ALT_PROTOCOL_VERSION, args:new string[] { "-conf=destream.conf", "-datadir=" + dataDir }, loadConfiguration:false);
var node = BuildFullNode(nodeSettings, this.callback); var node = BuildFullNode(nodeSettings, this.callback);
......
...@@ -34,27 +34,27 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -34,27 +34,27 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(105); // coinbase maturity = 100 destreamNodeSync.GenerateDeStream(105); // coinbase maturity = 100
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
var block = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(4).HashBlock).Result; var block = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(4).HashBlock).Result;
var prevTrx = block.Transactions.First(); var prevTrx = block.Transactions.First();
var dest = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey))); tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey)));
tx.AddOutput(new TxOut("25", dest.PubKey.Hash)); tx.AddOutput(new TxOut("25", dest.PubKey.Hash));
tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee
tx.Sign(stratisNodeSync.MinerSecret, false); tx.Sign(destreamNodeSync.MinerSecret, false);
stratisNodeSync.Broadcast(tx); destreamNodeSync.Broadcast(tx);
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 1); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 1);
} }
} }
...@@ -63,31 +63,31 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -63,31 +63,31 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(105); // coinbase maturity = 100 destreamNodeSync.GenerateDeStream(105); // coinbase maturity = 100
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
var block = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(4).HashBlock).Result; var block = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(4).HashBlock).Result;
var prevTrx = block.Transactions.First(); var prevTrx = block.Transactions.First();
var dest1 = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest1 = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
var dest2 = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest2 = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
Transaction parentTx = new Transaction(); Transaction parentTx = new Transaction();
parentTx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey))); parentTx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey)));
parentTx.AddOutput(new TxOut("25", dest1.PubKey.Hash)); parentTx.AddOutput(new TxOut("25", dest1.PubKey.Hash));
parentTx.AddOutput(new TxOut("24", dest2.PubKey.Hash)); // 1 btc fee parentTx.AddOutput(new TxOut("24", dest2.PubKey.Hash)); // 1 btc fee
parentTx.Sign(stratisNodeSync.MinerSecret, false); parentTx.Sign(destreamNodeSync.MinerSecret, false);
stratisNodeSync.Broadcast(parentTx); destreamNodeSync.Broadcast(parentTx);
// wiat for the trx to enter the pool // wiat for the trx to enter the pool
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 1); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 1);
// mine the transactions in the mempool // mine the transactions in the mempool
stratisNodeSync.GenerateDeStream(1, stratisNodeSync.FullNode.MempoolManager().InfoAllAsync().Result.Select(s => s.Trx).ToList()); destreamNodeSync.GenerateDeStream(1, destreamNodeSync.FullNode.MempoolManager().InfoAllAsync().Result.Select(s => s.Trx).ToList());
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 0); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 0);
//create a new trx spending both outputs //create a new trx spending both outputs
Transaction tx = new Transaction(); Transaction tx = new Transaction();
...@@ -96,8 +96,8 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -96,8 +96,8 @@ namespace DeStream.Bitcoin.IntegrationTests
tx.AddOutput(new TxOut("48", new Key().PubKey.Hash)); // 1 btc fee tx.AddOutput(new TxOut("48", new Key().PubKey.Hash)); // 1 btc fee
var signed = new TransactionBuilder().AddKeys(dest1, dest2).AddCoins(parentTx.Outputs.AsCoins()).SignTransaction(tx); var signed = new TransactionBuilder().AddKeys(dest1, dest2).AddCoins(parentTx.Outputs.AsCoins()).SignTransaction(tx);
stratisNodeSync.Broadcast(signed); destreamNodeSync.Broadcast(signed);
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 1); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 1);
} }
} }
...@@ -106,36 +106,36 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -106,36 +106,36 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(201); // coinbase maturity = 100 destreamNodeSync.GenerateDeStream(201); // coinbase maturity = 100
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
var trxs = new List<Transaction>(); var trxs = new List<Transaction>();
foreach (var index in Enumerable.Range(1, 100)) foreach (var index in Enumerable.Range(1, 100))
{ {
var block = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(index).HashBlock).Result; var block = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(index).HashBlock).Result;
var prevTrx = block.Transactions.First(); var prevTrx = block.Transactions.First();
var dest = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey))); tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey)));
tx.AddOutput(new TxOut("25", dest.PubKey.Hash)); tx.AddOutput(new TxOut("25", dest.PubKey.Hash));
tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee
tx.Sign(stratisNodeSync.MinerSecret, false); tx.Sign(destreamNodeSync.MinerSecret, false);
trxs.Add(tx); trxs.Add(tx);
} }
var options = new ParallelOptions { MaxDegreeOfParallelism = 10 }; var options = new ParallelOptions { MaxDegreeOfParallelism = 10 };
Parallel.ForEach(trxs, options, transaction => Parallel.ForEach(trxs, options, transaction =>
{ {
stratisNodeSync.Broadcast(transaction); destreamNodeSync.Broadcast(transaction);
}); });
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 100); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 100);
} }
} }
...@@ -144,22 +144,22 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -144,22 +144,22 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNodeSync.FullNode.Settings.RequireStandard = true; // make sure to test standard tx destreamNodeSync.FullNode.Settings.RequireStandard = true; // make sure to test standard tx
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(100); // coinbase maturity = 100 destreamNodeSync.GenerateDeStream(100); // coinbase maturity = 100
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
// Make sure skipping validation of transctions that were // Make sure skipping validation of transctions that were
// validated going into the memory pool does not allow // validated going into the memory pool does not allow
// double-spends in blocks to pass validation when they should not. // double-spends in blocks to pass validation when they should not.
var scriptPubKey = PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey); var scriptPubKey = PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey);
var genBlock = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(1).HashBlock).Result; var genBlock = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(1).HashBlock).Result;
// Create a double-spend of mature coinbase txn: // Create a double-spend of mature coinbase txn:
List<Transaction> spends = new List<Transaction>(2); List<Transaction> spends = new List<Transaction>(2);
...@@ -169,40 +169,40 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -169,40 +169,40 @@ namespace DeStream.Bitcoin.IntegrationTests
trx.AddInput(new TxIn(new OutPoint(genBlock.Transactions[0].GetHash(), 0), scriptPubKey)); trx.AddInput(new TxIn(new OutPoint(genBlock.Transactions[0].GetHash(), 0), scriptPubKey));
trx.AddOutput(Money.Cents(11), new Key().PubKey.Hash); trx.AddOutput(Money.Cents(11), new Key().PubKey.Hash);
// Sign: // Sign:
trx.Sign(stratisNodeSync.MinerSecret, false); trx.Sign(destreamNodeSync.MinerSecret, false);
spends.Add(trx); spends.Add(trx);
} }
// Test 1: block with both of those transactions should be rejected. // Test 1: block with both of those transactions should be rejected.
var block = stratisNodeSync.GenerateDeStream(1, spends).Single(); var block = destreamNodeSync.GenerateDeStream(1, spends).Single();
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
Assert.True(stratisNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash()); Assert.True(destreamNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash());
// Test 2: ... and should be rejected if spend1 is in the memory pool // Test 2: ... and should be rejected if spend1 is in the memory pool
Assert.True(stratisNodeSync.AddToDeStreamMempool(spends[0])); Assert.True(destreamNodeSync.AddToDeStreamMempool(spends[0]));
block = stratisNodeSync.GenerateDeStream(1, spends).Single(); block = destreamNodeSync.GenerateDeStream(1, spends).Single();
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
Assert.True(stratisNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash()); Assert.True(destreamNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash());
stratisNodeSync.FullNode.MempoolManager().Clear().Wait(); destreamNodeSync.FullNode.MempoolManager().Clear().Wait();
// Test 3: ... and should be rejected if spend2 is in the memory pool // Test 3: ... and should be rejected if spend2 is in the memory pool
Assert.True(stratisNodeSync.AddToDeStreamMempool(spends[1])); Assert.True(destreamNodeSync.AddToDeStreamMempool(spends[1]));
block = stratisNodeSync.GenerateDeStream(1, spends).Single(); block = destreamNodeSync.GenerateDeStream(1, spends).Single();
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
Assert.True(stratisNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash()); Assert.True(destreamNodeSync.FullNode.Chain.Tip.HashBlock != block.GetHash());
stratisNodeSync.FullNode.MempoolManager().Clear().Wait(); destreamNodeSync.FullNode.MempoolManager().Clear().Wait();
// Final sanity test: first spend in mempool, second in block, that's OK: // Final sanity test: first spend in mempool, second in block, that's OK:
List<Transaction> oneSpend = new List<Transaction>(); List<Transaction> oneSpend = new List<Transaction>();
oneSpend.Add(spends[0]); oneSpend.Add(spends[0]);
Assert.True(stratisNodeSync.AddToDeStreamMempool(spends[1])); Assert.True(destreamNodeSync.AddToDeStreamMempool(spends[1]));
block = stratisNodeSync.GenerateDeStream(1, oneSpend).Single(); block = destreamNodeSync.GenerateDeStream(1, oneSpend).Single();
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
Assert.True(stratisNodeSync.FullNode.Chain.Tip.HashBlock == block.GetHash()); Assert.True(destreamNodeSync.FullNode.Chain.Tip.HashBlock == block.GetHash());
// spends[1] should have been removed from the mempool when the // spends[1] should have been removed from the mempool when the
// block with spends[0] is accepted: // block with spends[0] is accepted:
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.MempoolManager().MempoolSize().Result == 0); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.MempoolManager().MempoolSize().Result == 0);
} }
} }
...@@ -219,65 +219,65 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -219,65 +219,65 @@ namespace DeStream.Bitcoin.IntegrationTests
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode = builder.CreateDeStreamPowNode(); var destreamNode = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNode.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNode.FullNode.Network)); destreamNode.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNode.FullNode.Network));
// 50 orphan transactions: // 50 orphan transactions:
for (ulong i = 0; i < 50; i++) for (ulong i = 0; i < 50; i++)
{ {
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(randHash(), 0), new Script(OpcodeType.OP_1))); tx.AddInput(new TxIn(new OutPoint(randHash(), 0), new Script(OpcodeType.OP_1)));
tx.AddOutput(new TxOut(new Money(1 * Money.CENT), stratisNode.MinerSecret.ScriptPubKey)); tx.AddOutput(new TxOut(new Money(1 * Money.CENT), destreamNode.MinerSecret.ScriptPubKey));
stratisNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Wait(); destreamNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Wait();
} }
Assert.Equal(50, stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count); Assert.Equal(50, destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count);
// ... and 50 that depend on other orphans: // ... and 50 that depend on other orphans:
for (ulong i = 0; i < 50; i++) for (ulong i = 0; i < 50; i++)
{ {
var txPrev = stratisNode.FullNode.MempoolManager().Orphans.OrphansList().ElementAt(rand.Next(stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count)); var txPrev = destreamNode.FullNode.MempoolManager().Orphans.OrphansList().ElementAt(rand.Next(destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count));
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(txPrev.Tx.GetHash(), 0), new Script(OpcodeType.OP_1))); tx.AddInput(new TxIn(new OutPoint(txPrev.Tx.GetHash(), 0), new Script(OpcodeType.OP_1)));
tx.AddOutput(new TxOut(new Money((1 + i + 100) * Money.CENT), stratisNode.MinerSecret.ScriptPubKey)); tx.AddOutput(new TxOut(new Money((1 + i + 100) * Money.CENT), destreamNode.MinerSecret.ScriptPubKey));
stratisNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Wait(); destreamNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Wait();
} }
Assert.Equal(100, stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count); Assert.Equal(100, destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count);
// This really-big orphan should be ignored: // This really-big orphan should be ignored:
for (ulong i = 0; i < 10; i++) for (ulong i = 0; i < 10; i++)
{ {
var txPrev = stratisNode.FullNode.MempoolManager().Orphans.OrphansList().ElementAt(rand.Next(stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count)); var txPrev = destreamNode.FullNode.MempoolManager().Orphans.OrphansList().ElementAt(rand.Next(destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count));
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddOutput(new TxOut(new Money(1 * Money.CENT), stratisNode.MinerSecret.ScriptPubKey)); tx.AddOutput(new TxOut(new Money(1 * Money.CENT), destreamNode.MinerSecret.ScriptPubKey));
foreach (var index in Enumerable.Range(0, 2777)) foreach (var index in Enumerable.Range(0, 2777))
tx.AddInput(new TxIn(new OutPoint(txPrev.Tx.GetHash(), index), new Script(OpcodeType.OP_1))); tx.AddInput(new TxIn(new OutPoint(txPrev.Tx.GetHash(), index), new Script(OpcodeType.OP_1)));
Assert.False(stratisNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Result); Assert.False(destreamNode.FullNode.MempoolManager().Orphans.AddOrphanTx(i, tx).Result);
} }
Assert.Equal(100, stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count); Assert.Equal(100, destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count);
// Test EraseOrphansFor: // Test EraseOrphansFor:
for (ulong i = 0; i < 3; i++) for (ulong i = 0; i < 3; i++)
{ {
var sizeBefore = stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count; var sizeBefore = destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count;
stratisNode.FullNode.MempoolManager().Orphans.EraseOrphansFor(i).Wait(); destreamNode.FullNode.MempoolManager().Orphans.EraseOrphansFor(i).Wait();
Assert.True(stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count < sizeBefore); Assert.True(destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count < sizeBefore);
} }
// Test LimitOrphanTxSize() function: // Test LimitOrphanTxSize() function:
stratisNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(40).Wait(); destreamNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(40).Wait();
Assert.True(stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count <= 40); Assert.True(destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count <= 40);
stratisNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(10).Wait(); destreamNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(10).Wait();
Assert.True(stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Count <= 10); Assert.True(destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Count <= 10);
stratisNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(0).Wait(); destreamNode.FullNode.MempoolManager().Orphans.LimitOrphanTxSizeAsync(0).Wait();
Assert.True(!stratisNode.FullNode.MempoolManager().Orphans.OrphansList().Any()); Assert.True(!destreamNode.FullNode.MempoolManager().Orphans.OrphansList().Any());
} }
} }
...@@ -286,40 +286,40 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -286,40 +286,40 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(101); // coinbase maturity = 100 destreamNodeSync.GenerateDeStream(101); // coinbase maturity = 100
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ConsensusLoop().Tip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.ChainBehaviorState.ConsensusTip.HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.ChainBehaviorState.ConsensusTip.HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.HighestPersistedBlock().HashBlock == stratisNodeSync.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.HighestPersistedBlock().HashBlock == destreamNodeSync.FullNode.Chain.Tip.HashBlock);
var block = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(1).HashBlock).Result; var block = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(1).HashBlock).Result;
var prevTrx = block.Transactions.First(); var prevTrx = block.Transactions.First();
var dest = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
var key = new Key(); var key = new Key();
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey))); tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey)));
tx.AddOutput(new TxOut("25", dest.PubKey.Hash)); tx.AddOutput(new TxOut("25", dest.PubKey.Hash));
tx.AddOutput(new TxOut("24", key.PubKey.Hash)); // 1 btc fee tx.AddOutput(new TxOut("24", key.PubKey.Hash)); // 1 btc fee
tx.Sign(stratisNodeSync.MinerSecret, false); tx.Sign(destreamNodeSync.MinerSecret, false);
Transaction txOrphan = new Transaction(); Transaction txOrphan = new Transaction();
txOrphan.AddInput(new TxIn(new OutPoint(tx.GetHash(), 1), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(key.PubKey))); txOrphan.AddInput(new TxIn(new OutPoint(tx.GetHash(), 1), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(key.PubKey)));
txOrphan.AddOutput(new TxOut("10", new Key().PubKey.Hash)); txOrphan.AddOutput(new TxOut("10", new Key().PubKey.Hash));
txOrphan.Sign(key.GetBitcoinSecret(stratisNodeSync.FullNode.Network), false); txOrphan.Sign(key.GetBitcoinSecret(destreamNodeSync.FullNode.Network), false);
// broadcast the orphan // broadcast the orphan
stratisNodeSync.Broadcast(txOrphan); destreamNodeSync.Broadcast(txOrphan);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.MempoolManager().Orphans.OrphansList().Count == 1); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.MempoolManager().Orphans.OrphansList().Count == 1);
// broadcast the parent // broadcast the parent
stratisNodeSync.Broadcast(tx); destreamNodeSync.Broadcast(tx);
TestHelper.WaitLoop(() => stratisNodeSync.FullNode.MempoolManager().Orphans.OrphansList().Count == 0); TestHelper.WaitLoop(() => destreamNodeSync.FullNode.MempoolManager().Orphans.OrphansList().Count == 0);
// wait for orphan to get in the pool // wait for orphan to get in the pool
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 2); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 2);
} }
} }
...@@ -328,69 +328,69 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -328,69 +328,69 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
var stratisNode1 = builder.CreateDeStreamPowNode(); var destreamNode1 = builder.CreateDeStreamPowNode();
var stratisNode2 = builder.CreateDeStreamPowNode(); var destreamNode2 = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
stratisNode1.NotInIBD(); destreamNode1.NotInIBD();
stratisNode2.NotInIBD(); destreamNode2.NotInIBD();
// generate blocks and wait for the downloader to pickup // generate blocks and wait for the downloader to pickup
stratisNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStreamWithMiner(105); // coinbase maturity = 100 destreamNodeSync.GenerateDeStreamWithMiner(105); // coinbase maturity = 100
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisNodeSync)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamNodeSync));
// sync both nodes // sync both nodes
stratisNode1.CreateRPCClient().AddNode(stratisNodeSync.Endpoint, true); destreamNode1.CreateRPCClient().AddNode(destreamNodeSync.Endpoint, true);
stratisNode2.CreateRPCClient().AddNode(stratisNodeSync.Endpoint, true); destreamNode2.CreateRPCClient().AddNode(destreamNodeSync.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisNode1, stratisNodeSync)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamNode1, destreamNodeSync));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisNode2, stratisNodeSync)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamNode2, destreamNodeSync));
// create some transactions and push them to the pool // create some transactions and push them to the pool
var trxs = new List<Transaction>(); var trxs = new List<Transaction>();
foreach (var index in Enumerable.Range(1, 5)) foreach (var index in Enumerable.Range(1, 5))
{ {
var block = stratisNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(stratisNodeSync.FullNode.Chain.GetBlock(index).HashBlock).Result; var block = destreamNodeSync.FullNode.BlockStoreManager().BlockRepository.GetAsync(destreamNodeSync.FullNode.Chain.GetBlock(index).HashBlock).Result;
var prevTrx = block.Transactions.First(); var prevTrx = block.Transactions.First();
var dest = new BitcoinSecret(new Key(), stratisNodeSync.FullNode.Network); var dest = new BitcoinSecret(new Key(), destreamNodeSync.FullNode.Network);
Transaction tx = new Transaction(); Transaction tx = new Transaction();
tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(stratisNodeSync.MinerSecret.PubKey))); tx.AddInput(new TxIn(new OutPoint(prevTrx.GetHash(), 0), PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(destreamNodeSync.MinerSecret.PubKey)));
tx.AddOutput(new TxOut("25", dest.PubKey.Hash)); tx.AddOutput(new TxOut("25", dest.PubKey.Hash));
tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee tx.AddOutput(new TxOut("24", new Key().PubKey.Hash)); // 1 btc fee
tx.Sign(stratisNodeSync.MinerSecret, false); tx.Sign(destreamNodeSync.MinerSecret, false);
trxs.Add(tx); trxs.Add(tx);
} }
var options = new ParallelOptions { MaxDegreeOfParallelism = 5 }; var options = new ParallelOptions { MaxDegreeOfParallelism = 5 };
Parallel.ForEach(trxs, options, transaction => Parallel.ForEach(trxs, options, transaction =>
{ {
stratisNodeSync.Broadcast(transaction); destreamNodeSync.Broadcast(transaction);
}); });
// wait for all nodes to have all trx // wait for all nodes to have all trx
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 5); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 5);
// the full node should be connected to both nodes // the full node should be connected to both nodes
Assert.True(stratisNodeSync.FullNode.ConnectionManager.ConnectedPeers.Count() >= 2); Assert.True(destreamNodeSync.FullNode.ConnectionManager.ConnectedPeers.Count() >= 2);
// reset the trickle timer on the full node that has the transactions in the pool // reset the trickle timer on the full node that has the transactions in the pool
foreach (var node in stratisNodeSync.FullNode.ConnectionManager.ConnectedPeers) node.Behavior<MempoolBehavior>().NextInvSend = 0; foreach (var node in destreamNodeSync.FullNode.ConnectionManager.ConnectedPeers) node.Behavior<MempoolBehavior>().NextInvSend = 0;
TestHelper.WaitLoop(() => stratisNode1.CreateRPCClient().GetRawMempool().Length == 5); TestHelper.WaitLoop(() => destreamNode1.CreateRPCClient().GetRawMempool().Length == 5);
TestHelper.WaitLoop(() => stratisNode2.CreateRPCClient().GetRawMempool().Length == 5); TestHelper.WaitLoop(() => destreamNode2.CreateRPCClient().GetRawMempool().Length == 5);
// mine the transactions in the mempool // mine the transactions in the mempool
stratisNodeSync.GenerateDeStreamWithMiner(1); destreamNodeSync.GenerateDeStreamWithMiner(1);
TestHelper.WaitLoop(() => stratisNodeSync.CreateRPCClient().GetRawMempool().Length == 0); TestHelper.WaitLoop(() => destreamNodeSync.CreateRPCClient().GetRawMempool().Length == 0);
// wait for block and mempool to change // wait for block and mempool to change
TestHelper.WaitLoop(() => stratisNode1.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode1.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
TestHelper.WaitLoop(() => stratisNode2.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode2.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
TestHelper.WaitLoop(() => stratisNode1.CreateRPCClient().GetRawMempool().Length == 0); TestHelper.WaitLoop(() => destreamNode1.CreateRPCClient().GetRawMempool().Length == 0);
TestHelper.WaitLoop(() => stratisNode2.CreateRPCClient().GetRawMempool().Length == 0); TestHelper.WaitLoop(() => destreamNode2.CreateRPCClient().GetRawMempool().Length == 0);
} }
} }
} }
......
...@@ -46,26 +46,26 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -46,26 +46,26 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode = builder.CreateDeStreamPowNode(); var destreamNode = builder.CreateDeStreamPowNode();
var coreNode = builder.CreateNode(); var coreNode = builder.CreateNode();
builder.StartAll(); builder.StartAll();
stratisNode.NotInIBD(); destreamNode.NotInIBD();
var tip = coreNode.FindBlock(10).Last(); var tip = coreNode.FindBlock(10).Last();
stratisNode.CreateRPCClient().AddNode(coreNode.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreNode.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash());
var bestBlockHash = stratisNode.CreateRPCClient().GetBestBlockHash(); var bestBlockHash = destreamNode.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
//Now check if Core connect to stratis //Now check if Core connect to destream
stratisNode.CreateRPCClient().RemoveNode(coreNode.Endpoint); destreamNode.CreateRPCClient().RemoveNode(coreNode.Endpoint);
TestHelper.WaitLoop(() => coreNode.CreateRPCClient().GetPeersInfo().Length == 0); TestHelper.WaitLoop(() => coreNode.CreateRPCClient().GetPeersInfo().Length == 0);
tip = coreNode.FindBlock(10).Last(); tip = coreNode.FindBlock(10).Last();
coreNode.CreateRPCClient().AddNode(stratisNode.Endpoint, true); coreNode.CreateRPCClient().AddNode(destreamNode.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash());
bestBlockHash = stratisNode.CreateRPCClient().GetBestBlockHash(); bestBlockHash = destreamNode.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
} }
} }
...@@ -75,29 +75,29 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -75,29 +75,29 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode = builder.CreateDeStreamPowNode(); var destreamNode = builder.CreateDeStreamPowNode();
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
var coreCreateNode = builder.CreateNode(); var coreCreateNode = builder.CreateNode();
builder.StartAll(); builder.StartAll();
stratisNode.NotInIBD(); destreamNode.NotInIBD();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
// first seed a core node with blocks and sync them to a stratis node // first seed a core node with blocks and sync them to a destream node
// and wait till the stratis node is fully synced // and wait till the destream node is fully synced
var tip = coreCreateNode.FindBlock(5).Last(); var tip = coreCreateNode.FindBlock(5).Last();
stratisNode.CreateRPCClient().AddNode(coreCreateNode.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreCreateNode.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreCreateNode.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreCreateNode.CreateRPCClient().GetBestBlockHash());
var bestBlockHash = stratisNode.CreateRPCClient().GetBestBlockHash(); var bestBlockHash = destreamNode.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
// add a new stratis node which will download // add a new destream node which will download
// the blocks using the GetData payload // the blocks using the GetData payload
stratisNodeSync.CreateRPCClient().AddNode(stratisNode.Endpoint, true); destreamNodeSync.CreateRPCClient().AddNode(destreamNode.Endpoint, true);
// wait for download and assert // wait for download and assert
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == stratisNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == destreamNodeSync.CreateRPCClient().GetBestBlockHash());
bestBlockHash = stratisNodeSync.CreateRPCClient().GetBestBlockHash(); bestBlockHash = destreamNodeSync.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
} }
} }
...@@ -107,29 +107,29 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -107,29 +107,29 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNode = builder.CreateDeStreamPowNode(); var destreamNode = builder.CreateDeStreamPowNode();
var coreNodeSync = builder.CreateNode(); var coreNodeSync = builder.CreateNode();
var coreCreateNode = builder.CreateNode(); var coreCreateNode = builder.CreateNode();
builder.StartAll(); builder.StartAll();
stratisNode.NotInIBD(); destreamNode.NotInIBD();
// first seed a core node with blocks and sync them to a stratis node // first seed a core node with blocks and sync them to a destream node
// and wait till the stratis node is fully synced // and wait till the destream node is fully synced
var tip = coreCreateNode.FindBlock(5).Last(); var tip = coreCreateNode.FindBlock(5).Last();
stratisNode.CreateRPCClient().AddNode(coreCreateNode.Endpoint, true); destreamNode.CreateRPCClient().AddNode(coreCreateNode.Endpoint, true);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreCreateNode.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreCreateNode.CreateRPCClient().GetBestBlockHash());
TestHelper.WaitLoop(() => stratisNode.FullNode.HighestPersistedBlock().HashBlock == stratisNode.FullNode.Chain.Tip.HashBlock); TestHelper.WaitLoop(() => destreamNode.FullNode.HighestPersistedBlock().HashBlock == destreamNode.FullNode.Chain.Tip.HashBlock);
var bestBlockHash = stratisNode.CreateRPCClient().GetBestBlockHash(); var bestBlockHash = destreamNode.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
// add a new stratis node which will download // add a new destream node which will download
// the blocks using the GetData payload // the blocks using the GetData payload
coreNodeSync.CreateRPCClient().AddNode(stratisNode.Endpoint, true); coreNodeSync.CreateRPCClient().AddNode(destreamNode.Endpoint, true);
// wait for download and assert // wait for download and assert
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNodeSync.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNodeSync.CreateRPCClient().GetBestBlockHash());
bestBlockHash = coreNodeSync.CreateRPCClient().GetBestBlockHash(); bestBlockHash = coreNodeSync.CreateRPCClient().GetBestBlockHash();
Assert.Equal(tip.GetHash(), bestBlockHash); Assert.Equal(tip.GetHash(), bestBlockHash);
} }
...@@ -146,74 +146,74 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -146,74 +146,74 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisMiner = builder.CreateDeStreamPosNode(); var destreamMiner = builder.CreateDeStreamPosNode();
var stratisSyncer = builder.CreateDeStreamPosNode(); var destreamSyncer = builder.CreateDeStreamPosNode();
var stratisReorg = builder.CreateDeStreamPosNode(); var destreamReorg = builder.CreateDeStreamPosNode();
builder.StartAll(); builder.StartAll();
stratisMiner.NotInIBD(); destreamMiner.NotInIBD();
stratisSyncer.NotInIBD(); destreamSyncer.NotInIBD();
stratisReorg.NotInIBD(); destreamReorg.NotInIBD();
// TODO: set the max allowed reorg threshold here // TODO: set the max allowed reorg threshold here
// assume a reorg of 10 blocks is not allowed. // assume a reorg of 10 blocks is not allowed.
stratisMiner.FullNode.ChainBehaviorState.MaxReorgLength = 10; destreamMiner.FullNode.ChainBehaviorState.MaxReorgLength = 10;
stratisSyncer.FullNode.ChainBehaviorState.MaxReorgLength = 10; destreamSyncer.FullNode.ChainBehaviorState.MaxReorgLength = 10;
stratisReorg.FullNode.ChainBehaviorState.MaxReorgLength = 10; destreamReorg.FullNode.ChainBehaviorState.MaxReorgLength = 10;
stratisMiner.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisMiner.FullNode.Network)); destreamMiner.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamMiner.FullNode.Network));
stratisReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisReorg.FullNode.Network)); destreamReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamReorg.FullNode.Network));
stratisMiner.GenerateDeStreamWithMiner(1); destreamMiner.GenerateDeStreamWithMiner(1);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisMiner)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamMiner));
stratisMiner.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamMiner.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisMiner.CreateRPCClient().AddNode(stratisSyncer.Endpoint, true); destreamMiner.CreateRPCClient().AddNode(destreamSyncer.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisMiner, stratisSyncer)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamMiner, destreamSyncer));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisMiner, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamMiner, destreamReorg));
// create a reorg by mining on two different chains // create a reorg by mining on two different chains
// ================================================ // ================================================
stratisMiner.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamMiner.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
stratisSyncer.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamSyncer.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisReorg)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamReorg));
var t1 = Task.Run(() => stratisMiner.GenerateDeStreamWithMiner(11)); var t1 = Task.Run(() => destreamMiner.GenerateDeStreamWithMiner(11));
var t2 = Task.Delay(1000).ContinueWith(t => stratisReorg.GenerateDeStreamWithMiner(12)); var t2 = Task.Delay(1000).ContinueWith(t => destreamReorg.GenerateDeStreamWithMiner(12));
Task.WaitAll(t1, t2); Task.WaitAll(t1, t2);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisMiner)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamMiner));
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisReorg)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamReorg));
// make sure the nodes are actually on different chains. // make sure the nodes are actually on different chains.
Assert.NotEqual(stratisMiner.FullNode.Chain.GetBlock(2).HashBlock, stratisReorg.FullNode.Chain.GetBlock(2).HashBlock); Assert.NotEqual(destreamMiner.FullNode.Chain.GetBlock(2).HashBlock, destreamReorg.FullNode.Chain.GetBlock(2).HashBlock);
TestHelper.TriggerSync(stratisSyncer); TestHelper.TriggerSync(destreamSyncer);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisMiner, stratisSyncer)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamMiner, destreamSyncer));
// The hash before the reorg node is connected. // The hash before the reorg node is connected.
var hashBeforeReorg = stratisMiner.FullNode.Chain.Tip.HashBlock; var hashBeforeReorg = destreamMiner.FullNode.Chain.Tip.HashBlock;
// connect the reorg chain // connect the reorg chain
stratisMiner.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamMiner.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSyncer.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSyncer.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
// trigger nodes to sync // trigger nodes to sync
TestHelper.TriggerSync(stratisMiner); TestHelper.TriggerSync(destreamMiner);
TestHelper.TriggerSync(stratisReorg); TestHelper.TriggerSync(destreamReorg);
TestHelper.TriggerSync(stratisSyncer); TestHelper.TriggerSync(destreamSyncer);
// wait for the synced chain to get headers updated. // wait for the synced chain to get headers updated.
TestHelper.WaitLoop(() => !stratisReorg.FullNode.ConnectionManager.ConnectedPeers.Any()); TestHelper.WaitLoop(() => !destreamReorg.FullNode.ConnectionManager.ConnectedPeers.Any());
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisMiner, stratisSyncer)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamMiner, destreamSyncer));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReorg, stratisMiner) == false); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReorg, destreamMiner) == false);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReorg, stratisSyncer) == false); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReorg, destreamSyncer) == false);
// check that a reorg did not happen. // check that a reorg did not happen.
Assert.Equal(hashBeforeReorg, stratisSyncer.FullNode.Chain.Tip.HashBlock); Assert.Equal(hashBeforeReorg, destreamSyncer.FullNode.Chain.Tip.HashBlock);
} }
} }
finally finally
...@@ -230,7 +230,6 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -230,7 +230,6 @@ namespace DeStream.Bitcoin.IntegrationTests
/// arrives from the puller. Then another block comes from the puller extending the chain without the block we mined. /// arrives from the puller. Then another block comes from the puller extending the chain without the block we mined.
/// </para> /// </para>
/// </summary> /// </summary>
/// <seealso cref="https://github.com/stratisproject/DeStreamBitcoinFullNode/issues/636"/>
[Fact] [Fact]
public void PullerVsMinerRaceCondition() public void PullerVsMinerRaceCondition()
{ {
...@@ -243,50 +242,50 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -243,50 +242,50 @@ namespace DeStream.Bitcoin.IntegrationTests
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
// This represents local node. // This represents local node.
var stratisMinerLocal = builder.CreateDeStreamPosNode(); var destreamMinerLocal = builder.CreateDeStreamPosNode();
// This represents remote, which blocks are received by local node using its puller. // This represents remote, which blocks are received by local node using its puller.
var stratisMinerRemote = builder.CreateDeStreamPosNode(); var destreamMinerRemote = builder.CreateDeStreamPosNode();
builder.StartAll(); builder.StartAll();
stratisMinerLocal.NotInIBD(); destreamMinerLocal.NotInIBD();
stratisMinerRemote.NotInIBD(); destreamMinerRemote.NotInIBD();
stratisMinerLocal.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisMinerLocal.FullNode.Network)); destreamMinerLocal.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamMinerLocal.FullNode.Network));
stratisMinerRemote.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisMinerRemote.FullNode.Network)); destreamMinerRemote.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamMinerRemote.FullNode.Network));
// Let's mine block Ap and Bp. // Let's mine block Ap and Bp.
stratisMinerRemote.GenerateDeStreamWithMiner(2); destreamMinerRemote.GenerateDeStreamWithMiner(2);
// Wait for block repository for block sync to work. // Wait for block repository for block sync to work.
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisMinerRemote)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamMinerRemote));
stratisMinerLocal.CreateRPCClient().AddNode(stratisMinerRemote.Endpoint, true); destreamMinerLocal.CreateRPCClient().AddNode(destreamMinerRemote.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisMinerLocal, stratisMinerRemote)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamMinerLocal, destreamMinerRemote));
// Now disconnect the peers and mine block C2p on remote. // Now disconnect the peers and mine block C2p on remote.
stratisMinerLocal.CreateRPCClient().RemoveNode(stratisMinerRemote.Endpoint); destreamMinerLocal.CreateRPCClient().RemoveNode(destreamMinerRemote.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisMinerRemote)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamMinerRemote));
// Mine block C2p. // Mine block C2p.
stratisMinerRemote.GenerateDeStreamWithMiner(1); destreamMinerRemote.GenerateDeStreamWithMiner(1);
Thread.Sleep(2000); Thread.Sleep(2000);
// Now reconnect nodes and mine block C1s before C2p arrives. // Now reconnect nodes and mine block C1s before C2p arrives.
stratisMinerLocal.CreateRPCClient().AddNode(stratisMinerRemote.Endpoint, true); destreamMinerLocal.CreateRPCClient().AddNode(destreamMinerRemote.Endpoint, true);
stratisMinerLocal.GenerateDeStreamWithMiner(1); destreamMinerLocal.GenerateDeStreamWithMiner(1);
// Mine block Dp. // Mine block Dp.
uint256 dpHash = stratisMinerRemote.GenerateDeStreamWithMiner(1)[0]; uint256 dpHash = destreamMinerRemote.GenerateDeStreamWithMiner(1)[0];
// Now we wait until the local node's chain tip has correct hash of Dp. // Now we wait until the local node's chain tip has correct hash of Dp.
TestHelper.WaitLoop(() => stratisMinerLocal.FullNode.Chain.Tip.HashBlock.Equals(dpHash)); TestHelper.WaitLoop(() => destreamMinerLocal.FullNode.Chain.Tip.HashBlock.Equals(dpHash));
// Then give it time to receive the block from the puller. // Then give it time to receive the block from the puller.
Thread.Sleep(2500); Thread.Sleep(2500);
// Check that local node accepted the Dp as consensus tip. // Check that local node accepted the Dp as consensus tip.
Assert.Equal(stratisMinerLocal.FullNode.ChainBehaviorState.ConsensusTip.HashBlock, dpHash); Assert.Equal(destreamMinerLocal.FullNode.ChainBehaviorState.ConsensusTip.HashBlock, dpHash);
} }
} }
finally finally
......
...@@ -28,7 +28,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -28,7 +28,7 @@ namespace DeStream.Bitcoin.IntegrationTests
coreNode.ConfigParameters.AddOrReplace("printtoconsole", "0"); coreNode.ConfigParameters.AddOrReplace("printtoconsole", "0");
coreNode.Start(); coreNode.Start();
CoreNode stratisNode = builder.CreateDeStreamPowNode(true, fullNodeBuilder => CoreNode destreamNode = builder.CreateDeStreamPowNode(true, fullNodeBuilder =>
{ {
fullNodeBuilder fullNodeBuilder
.UsePowConsensus() .UsePowConsensus()
...@@ -39,15 +39,14 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -39,15 +39,14 @@ namespace DeStream.Bitcoin.IntegrationTests
.AddRPC(); .AddRPC();
}); });
RPCClient stratisNodeRpc = stratisNode.CreateRPCClient(); RPCClient destreamNodeRpc = destreamNode.CreateRPCClient();
RPCClient coreRpc = coreNode.CreateRPCClient(); RPCClient coreRpc = coreNode.CreateRPCClient();
coreRpc.AddNode(stratisNode.Endpoint, false); coreRpc.AddNode(destreamNode.Endpoint, false);
stratisNodeRpc.AddNode(coreNode.Endpoint, false); destreamNodeRpc.AddNode(coreNode.Endpoint, false);
// core (in version 0.15.1) only mines segwit blocks above a certain height on regtest // core (in version 0.15.1) only mines segwit blocks above a certain height on regtest
// future versions of core will change that behaviour so this test may need to be changed in the future // future versions of core will change that behaviour so this test may need to be changed in the future
// see issue for more details https://github.com/stratisproject/DeStreamBitcoinFullNode/issues/1028
BIP9DeploymentsParameters prevSegwitDeployment = Network.RegTest.Consensus.BIP9Deployments[BIP9Deployments.Segwit]; BIP9DeploymentsParameters prevSegwitDeployment = Network.RegTest.Consensus.BIP9Deployments[BIP9Deployments.Segwit];
Network.RegTest.Consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 0, DateTime.Now.AddDays(50).ToUnixTimestamp()); Network.RegTest.Consensus.BIP9Deployments[BIP9Deployments.Segwit] = new BIP9DeploymentsParameters(1, 0, DateTime.Now.AddDays(50).ToUnixTimestamp());
...@@ -56,7 +55,7 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -56,7 +55,7 @@ namespace DeStream.Bitcoin.IntegrationTests
// generate 450 blocks, block 431 will be segwit activated. // generate 450 blocks, block 431 will be segwit activated.
coreRpc.Generate(450); coreRpc.Generate(450);
TestHelper.WaitLoop(() => stratisNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamNode.CreateRPCClient().GetBestBlockHash() == coreNode.CreateRPCClient().GetBestBlockHash());
// segwit activation on Bitcoin regtest. // segwit activation on Bitcoin regtest.
// - On regtest deployment state changes every 144 block, the threshold for activating a rule is 108 blocks. // - On regtest deployment state changes every 144 block, the threshold for activating a rule is 108 blocks.
...@@ -66,11 +65,11 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -66,11 +65,11 @@ namespace DeStream.Bitcoin.IntegrationTests
// - LockedIn 287 (as segwit should already be signaled in blocks). // - LockedIn 287 (as segwit should already be signaled in blocks).
// - Active at block 431. // - Active at block 431.
IConsensusLoop consensusLoop = stratisNode.FullNode.NodeService<IConsensusLoop>(); IConsensusLoop consensusLoop = destreamNode.FullNode.NodeService<IConsensusLoop>();
ThresholdState[] segwitDefinedState = consensusLoop.NodeDeployments.BIP9.GetStates(stratisNode.FullNode.Chain.GetBlock(142)); ThresholdState[] segwitDefinedState = consensusLoop.NodeDeployments.BIP9.GetStates(destreamNode.FullNode.Chain.GetBlock(142));
ThresholdState[] segwitStartedState = consensusLoop.NodeDeployments.BIP9.GetStates(stratisNode.FullNode.Chain.GetBlock(143)); ThresholdState[] segwitStartedState = consensusLoop.NodeDeployments.BIP9.GetStates(destreamNode.FullNode.Chain.GetBlock(143));
ThresholdState[] segwitLockedInState = consensusLoop.NodeDeployments.BIP9.GetStates(stratisNode.FullNode.Chain.GetBlock(287)); ThresholdState[] segwitLockedInState = consensusLoop.NodeDeployments.BIP9.GetStates(destreamNode.FullNode.Chain.GetBlock(287));
ThresholdState[] segwitActiveState = consensusLoop.NodeDeployments.BIP9.GetStates(stratisNode.FullNode.Chain.GetBlock(431)); ThresholdState[] segwitActiveState = consensusLoop.NodeDeployments.BIP9.GetStates(destreamNode.FullNode.Chain.GetBlock(431));
// check that segwit is got activated at block 431 // check that segwit is got activated at block 431
Assert.Equal(ThresholdState.Defined, segwitDefinedState.GetValue((int)BIP9Deployments.Segwit)); Assert.Equal(ThresholdState.Defined, segwitDefinedState.GetValue((int)BIP9Deployments.Segwit));
...@@ -87,8 +86,8 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -87,8 +86,8 @@ namespace DeStream.Bitcoin.IntegrationTests
private void TestSegwit_MinedOnDeStreamNode_ActivatedOn_CoreNode() private void TestSegwit_MinedOnDeStreamNode_ActivatedOn_CoreNode()
{ {
// TODO: mine segwit onh a stratis node on the bitcoin network // TODO: mine segwit onh a destream node on the bitcoin network
// write a tests that mines segwit blocks on the stratis node // write a tests that mines segwit blocks on the destream node
// and signals them to a core not, then segwit will get activated on core // and signals them to a core not, then segwit will get activated on core
} }
} }
......
...@@ -35,62 +35,62 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -35,62 +35,62 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisSender = builder.CreateDeStreamPowNode(); var destreamSender = builder.CreateDeStreamPowNode();
var stratisReceiver = builder.CreateDeStreamPowNode(); var destreamReceiver = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisSender.NotInIBD(); destreamSender.NotInIBD();
stratisReceiver.NotInIBD(); destreamReceiver.NotInIBD();
// get a key from the wallet // get a key from the wallet
var mnemonic1 = stratisSender.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic1 = destreamSender.FullNode.WalletManager().CreateWallet("123456", "mywallet");
var mnemonic2 = stratisReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic2 = destreamReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet");
Assert.Equal(12, mnemonic1.Words.Length); Assert.Equal(12, mnemonic1.Words.Length);
Assert.Equal(12, mnemonic2.Words.Length); Assert.Equal(12, mnemonic2.Words.Length);
var addr = stratisSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var addr = destreamSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var wallet = stratisSender.FullNode.WalletManager().GetWalletByName("mywallet"); var wallet = destreamSender.FullNode.WalletManager().GetWalletByName("mywallet");
var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey; var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey;
stratisSender.SetDummyMinerSecret(new BitcoinSecret(key, stratisSender.FullNode.Network)); destreamSender.SetDummyMinerSecret(new BitcoinSecret(key, destreamSender.FullNode.Network));
var maturity = (int)stratisSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity; var maturity = (int)destreamSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity;
stratisSender.GenerateDeStream(maturity + 5); destreamSender.GenerateDeStream(maturity + 5);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
// the mining should add coins to the wallet // the mining should add coins to the wallet
var total = stratisSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var total = destreamSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(Money.COIN * 105 * 50, total); Assert.Equal(Money.COIN * 105 * 50, total);
// sync both nodes // sync both nodes
stratisSender.CreateRPCClient().AddNode(stratisReceiver.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReceiver.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
// send coins to the receiver // send coins to the receiver
var sendto = stratisReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var sendto = destreamReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var trx = stratisSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext( var trx = destreamSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(
new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 100, FeeType.Medium, 101)); new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 100, FeeType.Medium, 101));
// broadcast to the other node // broadcast to the other node
stratisSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(trx.ToHex())); destreamSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(trx.ToHex()));
// wait for the trx to arrive // wait for the trx to arrive
TestHelper.WaitLoop(() => stratisReceiver.CreateRPCClient().GetRawMempool().Length > 0); TestHelper.WaitLoop(() => destreamReceiver.CreateRPCClient().GetRawMempool().Length > 0);
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any()); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any());
var receivetotal = stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var receivetotal = destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(Money.COIN * 100, receivetotal); Assert.Equal(Money.COIN * 100, receivetotal);
Assert.Null(stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); Assert.Null(destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
// generate two new blocks do the trx is confirmed // generate two new blocks do the trx is confirmed
stratisSender.GenerateDeStream(1, new List<Transaction>(new[] { trx.Clone() })); destreamSender.GenerateDeStream(1, new List<Transaction>(new[] { trx.Clone() }));
stratisSender.GenerateDeStream(1); destreamSender.GenerateDeStream(1);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => maturity + 6 == stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); TestHelper.WaitLoop(() => maturity + 6 == destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
} }
} }
...@@ -99,35 +99,35 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -99,35 +99,35 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
CoreNode stratisSender = builder.CreateDeStreamPowNode(); CoreNode destreamSender = builder.CreateDeStreamPowNode();
CoreNode stratisReceiver = builder.CreateDeStreamPowNode(); CoreNode destreamReceiver = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisSender.NotInIBD(); destreamSender.NotInIBD();
stratisReceiver.NotInIBD(); destreamReceiver.NotInIBD();
stratisSender.FullNode.WalletManager().CreateWallet("123456", "mywallet"); destreamSender.FullNode.WalletManager().CreateWallet("123456", "mywallet");
stratisReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet"); destreamReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet");
HdAddress addr = stratisSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); HdAddress addr = destreamSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
Wallet wallet = stratisSender.FullNode.WalletManager().GetWalletByName("mywallet"); Wallet wallet = destreamSender.FullNode.WalletManager().GetWalletByName("mywallet");
Key key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey; Key key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey;
stratisSender.SetDummyMinerSecret(new BitcoinSecret(key, stratisSender.FullNode.Network)); destreamSender.SetDummyMinerSecret(new BitcoinSecret(key, destreamSender.FullNode.Network));
int maturity = (int)stratisSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity; int maturity = (int)destreamSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity;
stratisSender.GenerateDeStreamWithMiner(maturity + 51); destreamSender.GenerateDeStreamWithMiner(maturity + 51);
// Wait for block repo for block sync to work. // Wait for block repo for block sync to work.
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
Assert.Equal(Money.COIN * 150 * 50, stratisSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount)); Assert.Equal(Money.COIN * 150 * 50, destreamSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount));
// Sync both nodes. // Sync both nodes.
stratisSender.CreateRPCClient().AddNode(stratisReceiver.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReceiver.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
// Get 50 unused addresses from the receiver. // Get 50 unused addresses from the receiver.
IEnumerable<HdAddress> recevierAddresses = stratisReceiver.FullNode.WalletManager() IEnumerable<HdAddress> recevierAddresses = destreamReceiver.FullNode.WalletManager()
.GetUnusedAddresses(new WalletAccountReference("mywallet", "account 0"), 50); .GetUnusedAddresses(new WalletAccountReference("mywallet", "account 0"), 50);
List<Recipient> recipients = recevierAddresses.Select(address => new Recipient List<Recipient> recipients = recevierAddresses.Select(address => new Recipient
...@@ -144,28 +144,28 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -144,28 +144,28 @@ namespace DeStream.Bitcoin.IntegrationTests
MinConfirmations = 101 MinConfirmations = 101
}; };
Transaction transaction = stratisSender.FullNode.WalletTransactionHandler().BuildTransaction(transactionBuildContext); Transaction transaction = destreamSender.FullNode.WalletTransactionHandler().BuildTransaction(transactionBuildContext);
Assert.Equal(51, transaction.Outputs.Count); Assert.Equal(51, transaction.Outputs.Count);
// Broadcast to the other node. // Broadcast to the other node.
stratisSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction.ToHex())); destreamSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction.ToHex()));
// Wait for the trx's to arrive. // Wait for the trx's to arrive.
TestHelper.WaitLoop(() => stratisReceiver.CreateRPCClient().GetRawMempool().Length > 0); TestHelper.WaitLoop(() => destreamReceiver.CreateRPCClient().GetRawMempool().Length > 0);
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any()); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any());
Assert.Equal(Money.COIN * 50, stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount)); Assert.Equal(Money.COIN * 50, destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount));
Assert.Null(stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); Assert.Null(destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
// Generate new blocks so the trx is confirmed. // Generate new blocks so the trx is confirmed.
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
// Wait for block repo for block sync to work. // Wait for block repo for block sync to work.
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
// Confirm trx's have been committed to the block. // Confirm trx's have been committed to the block.
Assert.Equal(maturity + 52 , stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); Assert.Equal(maturity + 52 , destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
} }
} }
...@@ -174,15 +174,15 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -174,15 +174,15 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
CoreNode stratisNodeSync = builder.CreateDeStreamPowNode(); CoreNode destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
// Move a wallet file to the right folder and restart the wallet manager to take it into account. // Move a wallet file to the right folder and restart the wallet manager to take it into account.
this.InitializeTestWallet(stratisNodeSync.FullNode.DataFolder.WalletPath); this.InitializeTestWallet(destreamNodeSync.FullNode.DataFolder.WalletPath);
var walletManager = stratisNodeSync.FullNode.NodeService<IWalletManager>() as WalletManager; var walletManager = destreamNodeSync.FullNode.NodeService<IWalletManager>() as WalletManager;
walletManager.Start(); walletManager.Start();
var rpc = stratisNodeSync.CreateRPCClient(); var rpc = destreamNodeSync.CreateRPCClient();
rpc.SendCommand(NBitcoin.RPC.RPCOperations.generate, 10); rpc.SendCommand(NBitcoin.RPC.RPCOperations.generate, 10);
Assert.Equal(10, rpc.GetBlockCount()); Assert.Equal(10, rpc.GetBlockCount());
...@@ -203,151 +203,151 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -203,151 +203,151 @@ namespace DeStream.Bitcoin.IntegrationTests
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisSender = builder.CreateDeStreamPowNode(); var destreamSender = builder.CreateDeStreamPowNode();
var stratisReceiver = builder.CreateDeStreamPowNode(); var destreamReceiver = builder.CreateDeStreamPowNode();
var stratisReorg = builder.CreateDeStreamPowNode(); var destreamReorg = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisSender.NotInIBD(); destreamSender.NotInIBD();
stratisReceiver.NotInIBD(); destreamReceiver.NotInIBD();
stratisReorg.NotInIBD(); destreamReorg.NotInIBD();
// get a key from the wallet // get a key from the wallet
var mnemonic1 = stratisSender.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic1 = destreamSender.FullNode.WalletManager().CreateWallet("123456", "mywallet");
var mnemonic2 = stratisReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic2 = destreamReceiver.FullNode.WalletManager().CreateWallet("123456", "mywallet");
Assert.Equal(12, mnemonic1.Words.Length); Assert.Equal(12, mnemonic1.Words.Length);
Assert.Equal(12, mnemonic2.Words.Length); Assert.Equal(12, mnemonic2.Words.Length);
var addr = stratisSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var addr = destreamSender.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var wallet = stratisSender.FullNode.WalletManager().GetWalletByName("mywallet"); var wallet = destreamSender.FullNode.WalletManager().GetWalletByName("mywallet");
var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey; var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey;
stratisSender.SetDummyMinerSecret(new BitcoinSecret(key, stratisSender.FullNode.Network)); destreamSender.SetDummyMinerSecret(new BitcoinSecret(key, destreamSender.FullNode.Network));
stratisReorg.SetDummyMinerSecret(new BitcoinSecret(key, stratisSender.FullNode.Network)); destreamReorg.SetDummyMinerSecret(new BitcoinSecret(key, destreamSender.FullNode.Network));
var maturity = (int)stratisSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity; var maturity = (int)destreamSender.FullNode.Network.Consensus.Option<PowConsensusOptions>().CoinbaseMaturity;
stratisSender.GenerateDeStreamWithMiner(maturity + 15); destreamSender.GenerateDeStreamWithMiner(maturity + 15);
var currentBestHeight = maturity + 15; var currentBestHeight = maturity + 15;
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
// the mining should add coins to the wallet // the mining should add coins to the wallet
var total = stratisSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var total = destreamSender.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(Money.COIN * currentBestHeight * 50, total); Assert.Equal(Money.COIN * currentBestHeight * 50, total);
// sync all nodes // sync all nodes
stratisReceiver.CreateRPCClient().AddNode(stratisSender.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamSender.Endpoint, true);
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
// Build Transaction 1 // Build Transaction 1
// ==================== // ====================
// send coins to the receiver // send coins to the receiver
var sendto = stratisReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var sendto = destreamReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var transaction1 = stratisSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 100, FeeType.Medium, 101)); var transaction1 = destreamSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 100, FeeType.Medium, 101));
// broadcast to the other node // broadcast to the other node
stratisSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction1.ToHex())); destreamSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction1.ToHex()));
// wait for the trx to arrive // wait for the trx to arrive
TestHelper.WaitLoop(() => stratisReceiver.CreateRPCClient().GetRawMempool().Length > 0); TestHelper.WaitLoop(() => destreamReceiver.CreateRPCClient().GetRawMempool().Length > 0);
Assert.NotNull(stratisReceiver.CreateRPCClient().GetRawTransaction(transaction1.GetHash(), false)); Assert.NotNull(destreamReceiver.CreateRPCClient().GetRawTransaction(transaction1.GetHash(), false));
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any()); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any());
var receivetotal = stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var receivetotal = destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(Money.COIN * 100, receivetotal); Assert.Equal(Money.COIN * 100, receivetotal);
Assert.Null(stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); Assert.Null(destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
// generate two new blocks so the trx is confirmed // generate two new blocks so the trx is confirmed
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
var transaction1MinedHeight = currentBestHeight + 1; var transaction1MinedHeight = currentBestHeight + 1;
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
currentBestHeight = currentBestHeight + 2; currentBestHeight = currentBestHeight + 2;
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
Assert.Equal(currentBestHeight, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(currentBestHeight, destreamReceiver.FullNode.Chain.Tip.Height);
TestHelper.WaitLoop(() => transaction1MinedHeight == stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); TestHelper.WaitLoop(() => transaction1MinedHeight == destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
// Build Transaction 2 // Build Transaction 2
// ==================== // ====================
// remove the reorg node // remove the reorg node
stratisReceiver.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamReceiver.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
stratisSender.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamSender.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisReorg)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamReorg));
var forkblock = stratisReceiver.FullNode.Chain.Tip; var forkblock = destreamReceiver.FullNode.Chain.Tip;
// send more coins to the wallet // send more coins to the wallet
sendto = stratisReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); sendto = destreamReceiver.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var transaction2 = stratisSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 10, FeeType.Medium, 101)); var transaction2 = destreamSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(new WalletAccountReference("mywallet", "account 0"), "123456", sendto.ScriptPubKey, Money.COIN * 10, FeeType.Medium, 101));
stratisSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction2.ToHex())); destreamSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction2.ToHex()));
// wait for the trx to arrive // wait for the trx to arrive
TestHelper.WaitLoop(() => stratisReceiver.CreateRPCClient().GetRawMempool().Length > 0); TestHelper.WaitLoop(() => destreamReceiver.CreateRPCClient().GetRawMempool().Length > 0);
Assert.NotNull(stratisReceiver.CreateRPCClient().GetRawTransaction(transaction2.GetHash(), false)); Assert.NotNull(destreamReceiver.CreateRPCClient().GetRawTransaction(transaction2.GetHash(), false));
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any()); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any());
var newamount = stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var newamount = destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(Money.COIN * 110, newamount); Assert.Equal(Money.COIN * 110, newamount);
Assert.Contains(stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet"), b => b.Transaction.BlockHeight == null); Assert.Contains(destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet"), b => b.Transaction.BlockHeight == null);
// mine more blocks so its included in the chain // mine more blocks so its included in the chain
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
var transaction2MinedHeight = currentBestHeight + 1; var transaction2MinedHeight = currentBestHeight + 1;
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
currentBestHeight = currentBestHeight + 2; currentBestHeight = currentBestHeight + 2;
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
Assert.Equal(currentBestHeight, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(currentBestHeight, destreamReceiver.FullNode.Chain.Tip.Height);
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any(b => b.Transaction.BlockHeight == transaction2MinedHeight)); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any(b => b.Transaction.BlockHeight == transaction2MinedHeight));
// create a reorg by mining on two different chains // create a reorg by mining on two different chains
// ================================================ // ================================================
// advance both chains, one chin is longer // advance both chains, one chin is longer
stratisSender.GenerateDeStreamWithMiner(2); destreamSender.GenerateDeStreamWithMiner(2);
stratisReorg.GenerateDeStreamWithMiner(10); destreamReorg.GenerateDeStreamWithMiner(10);
currentBestHeight = forkblock.Height + 10; currentBestHeight = forkblock.Height + 10;
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisReorg)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamReorg));
// connect the reorg chain // connect the reorg chain
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
// wait for the chains to catch up // wait for the chains to catch up
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
Assert.Equal(currentBestHeight, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(currentBestHeight, destreamReceiver.FullNode.Chain.Tip.Height);
// ensure wallet reorg complete // ensure wallet reorg complete
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().WalletTipHash == stratisReorg.CreateRPCClient().GetBestBlockHash()); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().WalletTipHash == destreamReorg.CreateRPCClient().GetBestBlockHash());
// check the wallet amount was rolled back // check the wallet amount was rolled back
var newtotal = stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var newtotal = destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(receivetotal, newtotal); Assert.Equal(receivetotal, newtotal);
TestHelper.WaitLoop(() => maturity + 16 == stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight); TestHelper.WaitLoop(() => maturity + 16 == destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").First().Transaction.BlockHeight);
// ReBuild Transaction 2 // ReBuild Transaction 2
// ==================== // ====================
// After the reorg transaction2 was returned back to mempool // After the reorg transaction2 was returned back to mempool
stratisSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction2.ToHex())); destreamSender.FullNode.NodeService<WalletController>().SendTransaction(new SendTransactionRequest(transaction2.ToHex()));
TestHelper.WaitLoop(() => stratisReceiver.CreateRPCClient().GetRawMempool().Length > 0); TestHelper.WaitLoop(() => destreamReceiver.CreateRPCClient().GetRawMempool().Length > 0);
// mine the transaction again // mine the transaction again
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
transaction2MinedHeight = currentBestHeight + 1; transaction2MinedHeight = currentBestHeight + 1;
stratisSender.GenerateDeStreamWithMiner(1); destreamSender.GenerateDeStreamWithMiner(1);
currentBestHeight = currentBestHeight + 2; currentBestHeight = currentBestHeight + 2;
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
Assert.Equal(currentBestHeight, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(currentBestHeight, destreamReceiver.FullNode.Chain.Tip.Height);
var newsecondamount = stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount); var newsecondamount = destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Sum(s => s.Transaction.Amount);
Assert.Equal(newamount, newsecondamount); Assert.Equal(newamount, newsecondamount);
TestHelper.WaitLoop(() => stratisReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any(b => b.Transaction.BlockHeight == transaction2MinedHeight)); TestHelper.WaitLoop(() => destreamReceiver.FullNode.WalletManager().GetSpendableTransactionsInWallet("mywallet").Any(b => b.Transaction.BlockHeight == transaction2MinedHeight));
} }
} }
...@@ -356,60 +356,60 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -356,60 +356,60 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisSender = builder.CreateDeStreamPowNode(); var destreamSender = builder.CreateDeStreamPowNode();
var stratisReceiver = builder.CreateDeStreamPowNode(); var destreamReceiver = builder.CreateDeStreamPowNode();
var stratisReorg = builder.CreateDeStreamPowNode(); var destreamReorg = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisSender.NotInIBD(); destreamSender.NotInIBD();
stratisReceiver.NotInIBD(); destreamReceiver.NotInIBD();
stratisReorg.NotInIBD(); destreamReorg.NotInIBD();
stratisSender.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisSender.FullNode.Network)); destreamSender.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamSender.FullNode.Network));
stratisReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisReorg.FullNode.Network)); destreamReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamReorg.FullNode.Network));
stratisSender.GenerateDeStreamWithMiner(10); destreamSender.GenerateDeStreamWithMiner(10);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
//// sync all nodes //// sync all nodes
stratisReceiver.CreateRPCClient().AddNode(stratisSender.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamSender.Endpoint, true);
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
// remove the reorg node // remove the reorg node
stratisReceiver.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamReceiver.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
stratisSender.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamSender.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisReorg)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamReorg));
// create a reorg by mining on two different chains // create a reorg by mining on two different chains
// ================================================ // ================================================
// advance both chains, one chin is longer // advance both chains, one chin is longer
stratisSender.GenerateDeStreamWithMiner(2); destreamSender.GenerateDeStreamWithMiner(2);
stratisReorg.GenerateDeStreamWithMiner(10); destreamReorg.GenerateDeStreamWithMiner(10);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisReorg)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamReorg));
// rewind the wallet in the stratisReceiver node // rewind the wallet in the destreamReceiver node
(stratisReceiver.FullNode.NodeService<IWalletSyncManager>() as WalletSyncManager).SyncFromHeight(5); (destreamReceiver.FullNode.NodeService<IWalletSyncManager>() as WalletSyncManager).SyncFromHeight(5);
// connect the reorg chain // connect the reorg chain
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
// wait for the chains to catch up // wait for the chains to catch up
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
Assert.Equal(20, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(20, destreamReceiver.FullNode.Chain.Tip.Height);
stratisSender.GenerateDeStreamWithMiner(5); destreamSender.GenerateDeStreamWithMiner(5);
TestHelper.TriggerSync(stratisReceiver); TestHelper.TriggerSync(destreamReceiver);
TestHelper.TriggerSync(stratisSender); TestHelper.TriggerSync(destreamSender);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
Assert.Equal(25, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(25, destreamReceiver.FullNode.Chain.Tip.Height);
} }
} }
...@@ -418,58 +418,58 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -418,58 +418,58 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisSender = builder.CreateDeStreamPowNode(); var destreamSender = builder.CreateDeStreamPowNode();
var stratisReceiver = builder.CreateDeStreamPowNode(); var destreamReceiver = builder.CreateDeStreamPowNode();
var stratisReorg = builder.CreateDeStreamPowNode(); var destreamReorg = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisSender.NotInIBD(); destreamSender.NotInIBD();
stratisReceiver.NotInIBD(); destreamReceiver.NotInIBD();
stratisReorg.NotInIBD(); destreamReorg.NotInIBD();
stratisSender.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisSender.FullNode.Network)); destreamSender.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamSender.FullNode.Network));
stratisReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), stratisReorg.FullNode.Network)); destreamReorg.SetDummyMinerSecret(new BitcoinSecret(new Key(), destreamReorg.FullNode.Network));
stratisSender.GenerateDeStreamWithMiner(10); destreamSender.GenerateDeStreamWithMiner(10);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
//// sync all nodes //// sync all nodes
stratisReceiver.CreateRPCClient().AddNode(stratisSender.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamSender.Endpoint, true);
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
// remove the reorg node and wait for node to be disconnected // remove the reorg node and wait for node to be disconnected
stratisReceiver.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamReceiver.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
stratisSender.CreateRPCClient().RemoveNode(stratisReorg.Endpoint); destreamSender.CreateRPCClient().RemoveNode(destreamReorg.Endpoint);
TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(stratisReorg)); TestHelper.WaitLoop(() => !TestHelper.IsNodeConnected(destreamReorg));
// create a reorg by mining on two different chains // create a reorg by mining on two different chains
// ================================================ // ================================================
// advance both chains, one chin is longer // advance both chains, one chin is longer
stratisSender.GenerateDeStreamWithMiner(2); destreamSender.GenerateDeStreamWithMiner(2);
stratisReorg.GenerateDeStreamWithMiner(10); destreamReorg.GenerateDeStreamWithMiner(10);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisSender)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamSender));
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisReorg)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamReorg));
// connect the reorg chain // connect the reorg chain
stratisReceiver.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamReceiver.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
stratisSender.CreateRPCClient().AddNode(stratisReorg.Endpoint, true); destreamSender.CreateRPCClient().AddNode(destreamReorg.Endpoint, true);
// wait for the chains to catch up // wait for the chains to catch up
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisReorg)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamReorg));
Assert.Equal(20, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(20, destreamReceiver.FullNode.Chain.Tip.Height);
// rewind the wallet in the stratisReceiver node // rewind the wallet in the destreamReceiver node
(stratisReceiver.FullNode.NodeService<IWalletSyncManager>() as WalletSyncManager).SyncFromHeight(10); (destreamReceiver.FullNode.NodeService<IWalletSyncManager>() as WalletSyncManager).SyncFromHeight(10);
stratisSender.GenerateDeStreamWithMiner(5); destreamSender.GenerateDeStreamWithMiner(5);
TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(stratisReceiver, stratisSender)); TestHelper.WaitLoop(() => TestHelper.AreNodesSynced(destreamReceiver, destreamSender));
Assert.Equal(25, stratisReceiver.FullNode.Chain.Tip.Height); Assert.Equal(25, destreamReceiver.FullNode.Chain.Tip.Height);
} }
} }
...@@ -478,29 +478,29 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -478,29 +478,29 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisminer = builder.CreateDeStreamPowNode(); var destreamminer = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisminer.NotInIBD(); destreamminer.NotInIBD();
// get a key from the wallet // get a key from the wallet
var mnemonic = stratisminer.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic = destreamminer.FullNode.WalletManager().CreateWallet("123456", "mywallet");
Assert.Equal(12, mnemonic.Words.Length); Assert.Equal(12, mnemonic.Words.Length);
var addr = stratisminer.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var addr = destreamminer.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var wallet = stratisminer.FullNode.WalletManager().GetWalletByName("mywallet"); var wallet = destreamminer.FullNode.WalletManager().GetWalletByName("mywallet");
var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey; var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey;
stratisminer.SetDummyMinerSecret(key.GetBitcoinSecret(stratisminer.FullNode.Network)); destreamminer.SetDummyMinerSecret(key.GetBitcoinSecret(destreamminer.FullNode.Network));
stratisminer.GenerateDeStream(10); destreamminer.GenerateDeStream(10);
// wait for block repo for block sync to work // wait for block repo for block sync to work
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisminer)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamminer));
// push the wallet back // push the wallet back
stratisminer.FullNode.Services.ServiceProvider.GetService<IWalletSyncManager>().SyncFromHeight(5); destreamminer.FullNode.Services.ServiceProvider.GetService<IWalletSyncManager>().SyncFromHeight(5);
stratisminer.GenerateDeStream(5); destreamminer.GenerateDeStream(5);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisminer)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamminer));
} }
} }
...@@ -509,28 +509,28 @@ namespace DeStream.Bitcoin.IntegrationTests ...@@ -509,28 +509,28 @@ namespace DeStream.Bitcoin.IntegrationTests
{ {
using (NodeBuilder builder = NodeBuilder.Create()) using (NodeBuilder builder = NodeBuilder.Create())
{ {
var stratisNodeSync = builder.CreateDeStreamPowNode(); var destreamNodeSync = builder.CreateDeStreamPowNode();
builder.StartAll(); builder.StartAll();
stratisNodeSync.NotInIBD(); destreamNodeSync.NotInIBD();
// get a key from the wallet // get a key from the wallet
var mnemonic = stratisNodeSync.FullNode.WalletManager().CreateWallet("123456", "mywallet"); var mnemonic = destreamNodeSync.FullNode.WalletManager().CreateWallet("123456", "mywallet");
Assert.Equal(12, mnemonic.Words.Length); Assert.Equal(12, mnemonic.Words.Length);
var addr = stratisNodeSync.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0")); var addr = destreamNodeSync.FullNode.WalletManager().GetUnusedAddress(new WalletAccountReference("mywallet", "account 0"));
var wallet = stratisNodeSync.FullNode.WalletManager().GetWalletByName("mywallet"); var wallet = destreamNodeSync.FullNode.WalletManager().GetWalletByName("mywallet");
var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey; var key = wallet.GetExtendedPrivateKeyForAddress("123456", addr).PrivateKey;
stratisNodeSync.SetDummyMinerSecret(key.GetBitcoinSecret(stratisNodeSync.FullNode.Network)); destreamNodeSync.SetDummyMinerSecret(key.GetBitcoinSecret(destreamNodeSync.FullNode.Network));
stratisNodeSync.GenerateDeStream(10); destreamNodeSync.GenerateDeStream(10);
TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(stratisNodeSync)); TestHelper.WaitLoop(() => TestHelper.IsNodeSynced(destreamNodeSync));
// set the tip of best chain some blocks in the apst // set the tip of best chain some blocks in the apst
stratisNodeSync.FullNode.Chain.SetTip(stratisNodeSync.FullNode.Chain.GetBlock(stratisNodeSync.FullNode.Chain.Height - 5)); destreamNodeSync.FullNode.Chain.SetTip(destreamNodeSync.FullNode.Chain.GetBlock(destreamNodeSync.FullNode.Chain.Height - 5));
// stop the node it will persist the chain with the reset tip // stop the node it will persist the chain with the reset tip
stratisNodeSync.FullNode.Dispose(); destreamNodeSync.FullNode.Dispose();
var newNodeInstance = builder.CloneDeStreamNode(stratisNodeSync); var newNodeInstance = builder.CloneDeStreamNode(destreamNodeSync);
// load the node, this should hit the block store recover code // load the node, this should hit the block store recover code
newNodeInstance.Start(); newNodeInstance.Start();
......
...@@ -27,7 +27,7 @@ namespace DeStream.Bitcoin.Utilities ...@@ -27,7 +27,7 @@ namespace DeStream.Bitcoin.Utilities
/// <returns><c>true</c> if the specified network is bitcoin, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the specified network is bitcoin, <c>false</c> otherwise.</returns>
public static bool IsBitcoin(this Network network) public static bool IsBitcoin(this Network network)
{ {
return !network.Name.ToLowerInvariant().Contains("stratis"); return !network.Name.ToLowerInvariant().Contains("destream");
} }
} }
} }
cd .. cd ..
start cmd /k dotnet run start cmd /k dotnet run
timeout 21 timeout 21
start cmd /k dotnet run stratis start cmd /k dotnet run destream
\ No newline at end of file
cd .. cd ..
start cmd /k dotnet run -testnet -debug=all -loglevel=debug start cmd /k dotnet run -testnet -debug=all -loglevel=debug
timeout 21 timeout 21
start cmd /k dotnet run stratis -testnet -debug=all -loglevel=debug start cmd /k dotnet run destream -testnet -debug=all -loglevel=debug
\ No newline at end of file
...@@ -26,7 +26,7 @@ namespace DeStream.BreezeD ...@@ -26,7 +26,7 @@ namespace DeStream.BreezeD
{ {
// Get the API uri. // Get the API uri.
var isTestNet = args.Contains("-testnet"); var isTestNet = args.Contains("-testnet");
var isDeStream = args.Contains("stratis"); var isDeStream = args.Contains("destream");
var isDestreamTest = args.Contains("-destreamtest"); var isDestreamTest = args.Contains("-destreamtest");
var agent = "Breeze"; var agent = "Breeze";
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
}, },
"DeStream Main": { "DeStream Main": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "stratis " "commandLineArgs": "destream "
}, },
"DeStream Test": { "DeStream Test": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "stratis -testnet -debug=all -loglevel=debug" "commandLineArgs": "destream -testnet -debug=all -loglevel=debug"
} }
} }
} }
\ No newline at end of file
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
}, },
"DeStream.DeStreamDnsD Test": { "DeStream.DeStreamDnsD Test": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "-testnet -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com" "commandLineArgs": "-testnet -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com"
}, },
"DeStream.DeStreamDnsD FullNode Test": { "DeStream.DeStreamDnsD FullNode Test": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "-testnet -dnsfullnode -dnslistenport=5399 -dnshostname=dns.stratisplatform.com -dnsnameserver=ns1.dns.stratisplatform.com -dnsmailbox=admin@stratisplatform.com" "commandLineArgs": "-testnet -dnsfullnode -dnslistenport=5399 -dnshostname=dns.destreamplatform.com -dnsnameserver=ns1.dns.destreamplatform.com -dnsmailbox=admin@destreamplatform.com"
} }
} }
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ using NBitcoin.RPC; ...@@ -13,7 +13,7 @@ using NBitcoin.RPC;
namespace NBitcoin.Tests namespace NBitcoin.Tests
{ {
// Require a stratis node running with the following stratis.conf file // Require a destream node running with the following destream.conf file
//server=1 //server=1
//rpcuser=rpcuser //rpcuser=rpcuser
//rpcpassword = rpcpassword //rpcpassword = rpcpassword
...@@ -111,8 +111,8 @@ namespace NBitcoin.Tests ...@@ -111,8 +111,8 @@ namespace NBitcoin.Tests
public void StartAll() public void StartAll()
{ {
if (!Process.GetProcesses().Any(p => p.ProcessName.Contains("stratis"))) if (!Process.GetProcesses().Any(p => p.ProcessName.Contains("destream")))
throw new NotSupportedException("stratis node is not running"); throw new NotSupportedException("destream node is not running");
//Task.WaitAll(Nodes.Where(n => n.State == CoreNodeState.Stopped).Select(n => n.StartAsync()).ToArray()); //Task.WaitAll(Nodes.Where(n => n.State == CoreNodeState.Stopped).Select(n => n.StartAsync()).ToArray());
} }
......
...@@ -14,7 +14,7 @@ namespace NBitcoin.Tests ...@@ -14,7 +14,7 @@ namespace NBitcoin.Tests
/* /*
* TODO: Consider importing to FN. * TODO: Consider importing to FN.
public static bool noClient = !Process.GetProcesses().Any(p => p.ProcessName.Contains("stratis")); public static bool noClient = !Process.GetProcesses().Any(p => p.ProcessName.Contains("destream"));
[Fact] [Fact]
[Trait("UnitTest", "UnitTest")] [Trait("UnitTest", "UnitTest")]
......
...@@ -15,7 +15,7 @@ namespace NBitcoin.Tests ...@@ -15,7 +15,7 @@ namespace NBitcoin.Tests
[Trait("RPCClient", "RPCClient")] [Trait("RPCClient", "RPCClient")]
public class pos_RPCClientTests public class pos_RPCClientTests
{ {
public static bool noClient = !Process.GetProcesses().Any(p => p.ProcessName.Contains("stratis")); public static bool noClient = !Process.GetProcesses().Any(p => p.ProcessName.Contains("destream"));
private const string TestAccount = "NBitcoin.RPCClientTests"; private const string TestAccount = "NBitcoin.RPCClientTests";
public pos_RPCClientTests() public pos_RPCClientTests()
......
...@@ -2418,7 +2418,7 @@ namespace NBitcoin.Tests ...@@ -2418,7 +2418,7 @@ namespace NBitcoin.Tests
private void tx_valid() private void tx_valid()
{ {
// test is disabled for now // test is disabled for now
// todo: get test data for the stratis blockchain // todo: get test data for the destream blockchain
// Read tests from test/data/tx_valid.json // Read tests from test/data/tx_valid.json
// Format is an array of arrays // Format is an array of arrays
...@@ -2539,7 +2539,7 @@ namespace NBitcoin.Tests ...@@ -2539,7 +2539,7 @@ namespace NBitcoin.Tests
private void tx_invalid() private void tx_invalid()
{ {
// test is disabled for now // test is disabled for now
// todo: get test data for the stratis blockchain // todo: get test data for the destream blockchain
// Read tests from test/data/tx_valid.json // Read tests from test/data/tx_valid.json
// Format is an array of arrays // Format is an array of arrays
......
...@@ -282,7 +282,7 @@ namespace NBitcoin ...@@ -282,7 +282,7 @@ namespace NBitcoin
public string Name { get; private set; } public string Name { get; private set; }
/// <summary> The name of the root folder containing blockchains operating with the same consensus rules (for now, this will be bitcoin or stratis). </summary> /// <summary> The name of the root folder containing blockchains operating with the same consensus rules (for now, this will be bitcoin or destream). </summary>
public string RootFolderName { get; private set; } public string RootFolderName { get; private set; }
/// <summary> The default name used for the network configuration file. </summary> /// <summary> The default name used for the network configuration file. </summary>
......
...@@ -45,10 +45,10 @@ namespace NBitcoin ...@@ -45,10 +45,10 @@ namespace NBitcoin
public const string BitcoinDefaultConfigFilename = "bitcoin.conf"; public const string BitcoinDefaultConfigFilename = "bitcoin.conf";
/// <summary> The name of the root folder containing the different DeStream blockchains (DeStreamMain, DeStreamTest, DeStreamRegTest). </summary> /// <summary> The name of the root folder containing the different DeStream blockchains (DeStreamMain, DeStreamTest, DeStreamRegTest). </summary>
public const string DeStreamRootFolderName = "stratis"; public const string DeStreamRootFolderName = "destream";
/// <summary> The default name used for the DeStream configuration file. </summary> /// <summary> The default name used for the DeStream configuration file. </summary>
public const string DeStreamDefaultConfigFilename = "stratis.conf"; public const string DeStreamDefaultConfigFilename = "destream.conf";
public static Network Main => Network.GetNetwork("Main") ?? InitMain(); public static Network Main => Network.GetNetwork("Main") ?? InitMain();
...@@ -379,10 +379,10 @@ namespace NBitcoin ...@@ -379,10 +379,10 @@ namespace NBitcoin
.AddDNSSeeds(new[] .AddDNSSeeds(new[]
{ {
new DNSSeedData("seednode1.stratisplatform.com", "seednode1.stratisplatform.com"), new DNSSeedData("seednode1.destreamplatform.com", "seednode1.destreamplatform.com"),
new DNSSeedData("seednode2.stratis.cloud", "seednode2.stratis.cloud"), new DNSSeedData("seednode2.destream.cloud", "seednode2.destream.cloud"),
new DNSSeedData("seednode3.stratisplatform.com", "seednode3.stratisplatform.com"), new DNSSeedData("seednode3.destreamplatform.com", "seednode3.destreamplatform.com"),
new DNSSeedData("seednode4.stratis.cloud", "seednode4.stratis.cloud") new DNSSeedData("seednode4.destream.cloud", "seednode4.destream.cloud")
}) })
.SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (63) }) .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { (63) })
...@@ -471,10 +471,10 @@ namespace NBitcoin ...@@ -471,10 +471,10 @@ namespace NBitcoin
.AddDNSSeeds(new[] .AddDNSSeeds(new[]
{ {
new DNSSeedData("testnet1.stratisplatform.com", "testnet1.stratisplatform.com"), new DNSSeedData("testnet1.destreamplatform.com", "testnet1.destreamplatform.com"),
new DNSSeedData("testnet2.stratisplatform.com", "testnet2.stratisplatform.com"), new DNSSeedData("testnet2.destreamplatform.com", "testnet2.destreamplatform.com"),
new DNSSeedData("testnet3.stratisplatform.com", "testnet3.stratisplatform.com"), new DNSSeedData("testnet3.destreamplatform.com", "testnet3.destreamplatform.com"),
new DNSSeedData("testnet4.stratisplatform.com", "testnet4.stratisplatform.com") new DNSSeedData("testnet4.destreamplatform.com", "testnet4.destreamplatform.com")
}); });
builder.AddSeeds(new[] builder.AddSeeds(new[]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment