Skip to content

Commit

Permalink
Merge pull request #21 from Glebegor/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
Glebegor committed Apr 21, 2024
2 parents 4ade0be + 98cc1f0 commit 454b423
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 8 deletions.
4 changes: 4 additions & 0 deletions BCAT/BCAT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Folder Include="Logger\" />
</ItemGroup>

</Project>
41 changes: 41 additions & 0 deletions BCAT/Bootstrap/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using BCAT.Entities.Commons.Clients;

namespace BCAT.Bootstrap;

public class App
{
public static Client client;

public static void SetClient()
{
int choise;
Console.WriteLine("Starting of the Client...");
Console.WriteLine("1. Node");
Console.WriteLine("2. Mining Node");
Console.WriteLine("3. Miner");
Console.WriteLine("4. Wallet");
choise = Convert.ToInt32(Console.ReadLine());
switch (choise)
{
case 1:
Console.WriteLine("You are Node");
client = new NodeCL();
break;
case 2:
Console.WriteLine("You are Mining Node");
client = new NodeMining();
break;
case 3:
Console.WriteLine("You are Miner");
client = new MinerCL();
break;
case 4:
Console.WriteLine("You are Wallet");
client = new WalletCL();
break;
default:
Console.WriteLine("Invalid choise");
break;
}
}
}
11 changes: 11 additions & 0 deletions BCAT/Entities/Commons/Clients/Client.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BCAT.Entities.Enums;

namespace BCAT.Entities.Commons.Clients;

public abstract class Client
{
public string host;
public string port;

public abstract void Run();
}
10 changes: 10 additions & 0 deletions BCAT/Entities/Commons/Clients/MinerCL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BCAT.Entities.Commons.Clients;

public class MinerCL : Client
{
public override void Run()
{
// Function to run mining server
}

}
10 changes: 10 additions & 0 deletions BCAT/Entities/Commons/Clients/Node-MiningCL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BCAT.Entities.Commons.Clients;

public class NodeMining : Client
{
public override void Run()
{
// Function to run server of the node mining
}

}
28 changes: 28 additions & 0 deletions BCAT/Entities/Commons/Clients/NodeCL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace BCAT.Entities.Commons.Clients;

public class NodeCL : Client
{
public List<string> nodesInNetwork;
public List<string> nodesMiningInNetwork;
public List<string> miningsInNetwork;
public List<string> walletsInNetwork;
public Blockchain blockchain;

public NodeCL()
{
nodesInNetwork = new List<string>();
nodesMiningInNetwork = new List<string>();
miningsInNetwork = new List<string>();
walletsInNetwork = new List<string>();
blockchain = new Blockchain();
}

public void UpdateData()
{
// Here need to be function that will update data from blockchain network
}
public override void Run()
{
// Function to run server of the node
}
}
9 changes: 9 additions & 0 deletions BCAT/Entities/Commons/Clients/WalletCL.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BCAT.Entities.Commons.Clients;

public class WalletCL : Client
{
public override void Run()
{

}
}
6 changes: 6 additions & 0 deletions BCAT/Entities/Commons/NFT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BCAT.Entities.Commons;

public class NFT
{

}
9 changes: 9 additions & 0 deletions BCAT/Entities/Enums/ClientTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BCAT.Entities.Enums;

public enum ClientTypes
{
Node,
NodeMining,
Mining,
Wallet
}
2 changes: 2 additions & 0 deletions BCAT/PrivateInfo/wallet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
31 changes: 23 additions & 8 deletions BCAT/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Security.Cryptography;
using BCAT.Bootstrap;
using BCAT.Entities.Interfaces;
using BCAT.Entities.Commons;
using BCAT.Entities.Commons.Clients;
using BCAT.Internal.Validators;

namespace BCAT;
Expand All @@ -13,21 +15,23 @@ public static void Main()
Blockchain blockchain = new Blockchain();

InitTest(blockchain);
BlockchainValidator blockchainValidator = new BlockchainValidator();

Console.WriteLine("Validating Blockchain...");
Console.WriteLine("Without changes->");
Console.WriteLine(BlockchainValidator.ValidateBlockchain(blockchain) ? "BLOCKCHAIN IS VALID" : "BLOCKCHAIN IS NOT VALID");

Console.WriteLine("With changes->");
blockchain.chain[1].prevHash = "123";
Console.WriteLine(BlockchainValidator.ValidateBlockchain(blockchain) ? "BLOCKCHAIN IS VALID" : "BLOCKCHAIN IS NOT VALID");
Console.WriteLine("Starting of the client.");
Console.WriteLine("Starting of the client.");
// END OF VERY BIG TEST


// Client initialization
App app = new App();
App.SetClient();
App.client.Run();

}


static public void InitTest(Blockchain blockchain)
{
// Wallet tests
Console.WriteLine("Creating Wallets...");

Console.WriteLine("Created wallet alice.");
Expand All @@ -38,6 +42,7 @@ static public void InitTest(Blockchain blockchain)
Console.WriteLine("Blockchain wallets:");
blockchain.wallets.ForEach(wallet => Console.WriteLine(wallet.SerializerToJsonString()));

// Transaction tests
Console.WriteLine("\n" + "Transaction 1.");
alice_wallet.SendTransaction(bob_wallet.publicKey, 50);
Console.WriteLine("Transaction 2.");
Expand All @@ -49,6 +54,16 @@ static public void InitTest(Blockchain blockchain)
Console.WriteLine("Blockchain wallets after transactions:");
blockchain.wallets.ForEach(wallet => Console.WriteLine(wallet.SerializerToJsonString()));

// Validate tests
BlockchainValidator blockchainValidator = new BlockchainValidator();

Console.WriteLine("Validating Blockchain...");
Console.WriteLine("Without changes->");
Console.WriteLine(BlockchainValidator.ValidateBlockchain(blockchain) ? "BLOCKCHAIN IS VALID" : "BLOCKCHAIN IS NOT VALID");

Console.WriteLine("With changes->");
blockchain.chain[1].prevHash = "123";
Console.WriteLine(BlockchainValidator.ValidateBlockchain(blockchain) ? "BLOCKCHAIN IS VALID" : "BLOCKCHAIN IS NOT VALID");
}
}

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# BCAT - Blockchain Anonymous Token

## Description
BCAT has 6 "I"t will be":
- It will be public blockchain.
- It will be anonymous.
- It will be fast.
- It will be secure.
- It will be scalable.
- It will be decentralized.

## Environment
## Docs
### Stack
Expand All @@ -9,6 +17,10 @@

### Main documentation
Wiki: [BCAT Wiki](https://github.com/Glebegor/BCAT/wiki)
### Protocol
Blockchain will has custom protocol - BCAT Protocol.</br>
BCAT need to work with blocks, transactions, wallets, mining etc.</br>
Protocol will use json format for data exchange.</br>

## Installation
## Usage
Expand Down

0 comments on commit 454b423

Please sign in to comment.