/// <summary> /// Attacker change a transfer in the middle of the chain and make the chain invalid /// </summary> public static void ChengeTransfer_SouldNotAffectTransferChain() { //Arrange var goofy = new Goofy(); var changer = new Signature(256); var person1 = new Person(); var person2 = new Person(); var trans1 = goofy.CreateCoin(changer.PublicKey); var changerSgndTrans = changer.SignMessage(trans1); var transInfo = new TransferInfo(changerSgndTrans, person1.PublicKey); var changerTransfer = trans1.PayTo(transInfo); person1.AddTransfer(changerTransfer); var tran3 = person1.PayTo(person2.PublicKey); //Act changerTransfer.Hash = null; changerTransfer.Info.DestinyPk = null; //Assert try { person2.CheckTransfers(tran3); } catch { Console.WriteLine("Transfer chain is broked because someone change a another transfer in the middle."); } }
public static void ReceivingAndMaekingManyTransfer_SouldHaveValidTransferChain() { //Arrange var goofy = new Goofy(); var person1 = new Person(); var person2 = new Person(); Global.GoofyPk = goofy.PublicKey; var trans1 = goofy.CreateCoin(person1.PublicKey); person1.AddTransfer(trans1); //Action var trans2 = person1.PayTo(person2.PublicKey); //Assert try { //testing the for loop checkTransfer person2.CheckTransfers(trans2); person2.AddTransfer(trans2); } catch (Exception e) { Console.WriteLine(e.Message); } }