Skip to content

Commit

Permalink
Merge pull request #88 from thenewboston-developers/develop
Browse files Browse the repository at this point in the history
Fixes for beta release
  • Loading branch information
Mirch authored Jan 23, 2021
2 parents ca44ade + 80f224a commit dbc92e9
Show file tree
Hide file tree
Showing 53 changed files with 128 additions and 927 deletions.
8 changes: 0 additions & 8 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ For projects that support adding a Nuget reference you may paste the following
* ConnectedBankService
* InvalidBlocksService
* TransactionsService
* UpgradeNoticeService
* ValidatorService
2. Common
*
3. Validator
* AccountsService
* BankBlockService
* ConfigService
* ConnectedBankService
* PrimaryValidatorUpdatedService
* TransactionService
* UpgradeRequestService
* ValidatorService
* ValidatorConfirmationBlockService

Expand Down Expand Up @@ -77,10 +74,8 @@ Description
## ConfigService
## ConfirmationService
## ConnectedBankService
## ConnectionRequestService
## InvalidBlocksService
## TransactionService
## UpgradeNoticeService
## ValidatorService
## Bank Exceptions (BNK)

Expand Down Expand Up @@ -109,14 +104,11 @@ Description
Thenewboston.Validator.Api
Thenewboston.Validator.Models
## AccountsService
## BankBlockService
## ConfigService
## ConfirmationService
## ConnectedBankService
## ConnectionRequestService
## PrimaryValidatorUpdatedService
## TransactionService
## UpgradeRequestService
## ValidatorService
## ValidatorConfirmationBlockService
## Validator Exceptions (VLD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,70 +47,6 @@ private PaginatedResponseModel<BankConfirmationBlock> CreateMockBankConfirmation
};
}

private ConfirmationBlock CreateMockConfirmationBlockMessage()
{
return new ConfirmationBlock()
{
Message = new ConfirmationBlockMessage()
{
Block = new ConfirmationBankBlock()
{
AccountNumber = "0cdd4ba04456ca169baca3d66eace869520c62fe84421329086e03d91a68acdb",
Message = new ConfirmationBankBlockMessage()
{
BalanceKey = "e6a41b658e17ab2db4355176c8160de6a66b07e5cbdd85244b55b38b4fd26e92",
Transactions = new List<ConfirmationBankBlockTransaction>()
{
new ConfirmationBankBlockTransaction()
{
Amount = "4",
Recipient = "484b3176c63d5f37d808404af1a12c4b9649cd6f6769f35bdf5a816133623fbc"
},
new ConfirmationBankBlockTransaction()
{
Amount = "1",
Recipient = "5e12967707909e62b2bb2036c209085a784fabbc3deccefee70052b6181c8ed8"
},
new ConfirmationBankBlockTransaction()
{
Amount = "4",
Recipient = "ad1f8845c6a1abb6011a2a434a079a087c460657aad54329a84b406dce8bf314"
}
}
}
},
Signature = "d857184b7d3121a8f9dccab09062fafc82dd0fb30a5d53e19ab25a587171bb9c6b33858353cd3ff7ddc1ad2bfc59a885e85827799bcfc082fd048f9bf34bd404"
},
UpdatedBalances = new List<ConfirmationUpdatedBalanceRecord>()
{
new ConfirmationUpdatedBalanceRecord()
{
AccountNumber = "0cdd4ba04456ca169baca3d66eace869520c62fe84421329086e03d91a68acdb",
Balance = "4294967014",
BalanceLock = "729ce6ce619aeedf260221c7687c51d8a6845fbb5407b11c8cd26eaa7c8a6125"
},
new ConfirmationUpdatedBalanceRecord()
{
AccountNumber = "484b3176c63d5f37d808404af1a12c4b9649cd6f6769f35bdf5a816133623fbc",
Balance = "191",
},
new ConfirmationUpdatedBalanceRecord()
{
AccountNumber = "5e12967707909e62b2bb2036c209085a784fabbc3deccefee70052b6181c8ed8",
Balance = "18",
},
new ConfirmationUpdatedBalanceRecord()
{
AccountNumber = "ad1f8845c6a1abb6011a2a434a079a087c460657aad54329a84b406dce8bf314",
Balance = "72",
}
},
BlockIdentifier = "4c9595b2b661a23e665256d6826ae940bd4ea82bef0c1ba7b3104e40a4c42b91",
NodeIdentifier = "3afdf37573f1a511def0bd85553404b7091a76bcd79cdcebba1310527b167521",
Signature = "b4d335fa7662216acba06c18d93c6cfb688c8057cbe9193ddc8e6fb3702ba1d979e43b09e06c6c7c38358bbee5243dc37a52c5212298c2259be48285e3da130c"
};
}

#endregion

#region Mock Service
Expand All @@ -128,17 +64,6 @@ private IBankConfirmationBlockService BuildConfirmationBlockGetMock()
return service;
}

private IBankConfirmationBlockService BuildConfirmationBlockPostMock()
{
var requestSenderMock = new Mock<IHttpRequestSender>();

requestSenderMock.Setup(s => s.PostAsync(It.IsAny<string>(), It.IsAny<HttpContent>()))
.ReturnsAsync(new HttpResponseMessage(System.Net.HttpStatusCode.Created));

IBankConfirmationBlockService service = new BankConfirmationBlockService(requestSenderMock.Object);
return service;
}

#endregion

#region Tests
Expand All @@ -153,14 +78,6 @@ public async void BankConfirmationBlockReturnedAsync()
Assert.Equal(expectedResult, actualResult);
}

[Fact]
public async void BankConfirmationBlockMessagePostedAsync()
{
var service = BuildConfirmationBlockPostMock();
var response = await service.PostConfirmationBlockAsync(CreateMockConfirmationBlockMessage());
Assert.True(response.StatusCode == System.Net.HttpStatusCode.Created);
}

#endregion
}
}
6 changes: 3 additions & 3 deletions src/Thenewboston.Tests/Bank/Api/BlocksServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ private Block CreateMockBlockMessage()
BalanceKey = "ce51f0d9facaa7d3e69657429dd3f961ce70077a8efb53dcda508c7c0a19d2e3",
Transactions = new List<BlockTransaction>() {
new BlockTransaction() {
Amount = "12.5",
Amount = 12.5,
Recipient = "484b3176c63d5f37d808404af1a12c4b9649cd6f6769f35bdf5a816133623fbc"
},
new BlockTransaction() {
Amount = "1", Recipient = "5e12967707909e62b2bb2036c209085a784fabbc3deccefee70052b6181c8ed8"
Amount = 1, Recipient = "5e12967707909e62b2bb2036c209085a784fabbc3deccefee70052b6181c8ed8"
},
new BlockTransaction() {
Amount = "4", Recipient = "ad1f8845c6a1abb6011a2a434a079a087c460657aad54329a84b406dce8bf314"
Amount = 4, Recipient = "ad1f8845c6a1abb6011a2a434a079a087c460657aad54329a84b406dce8bf314"
}
}
},
Expand Down
73 changes: 0 additions & 73 deletions src/Thenewboston.Tests/Bank/Api/ConnectionRequestServiceTest.cs

This file was deleted.

19 changes: 1 addition & 18 deletions src/Thenewboston.Tests/Bank/Api/InvalidBlockServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -41,18 +41,7 @@ public async void GetInvalidBlockWithPageOnlyPaginationReturnedSuccessCodeandDat
Assert.Equal("2bcd53c5-19f9-4226-ab04-3dfb17c3a1fe", invalidBankBlocks.Results.ElementAt(0).Id);
}
}
public class SendInvalidBankBlocksAsync
{
[Fact]
public async void SendInvalidBlockReturnedSuccessCodeandData()
{
var service = BuildBankInvalidServiceMock();
var invalidBankBlocks = await service.SendInvalidBlocksToBankAsync( new BankInvalidBlockRequest());

Assert.Equal("2bcd53c5-19f9-4226-ab04-3dfb17c3a1fe", invalidBankBlocks.Id);
}
}

private static List<BankInvalidBlock> INVALID_BLOCK_TEST_DATA = new List<BankInvalidBlock>
{
new BankInvalidBlock
Expand Down Expand Up @@ -99,13 +88,7 @@ private static InvalidBlocksService BuildBankInvalidServiceMock()
.Setup(x => x.GetAsync(It.IsAny<string>()))
.Returns(Task.FromResult(getAllResponse));

var postResponse = new HttpResponseMessage(System.Net.HttpStatusCode.OK);
postResponse.Content = new StringContent(JsonConvert.SerializeObject(INVALID_BLOCK_TEST_DATA.First()), Encoding.UTF8, "application/json");

//TODO Setup for more Scenarios
requestSender
.Setup(x => x.PostAsync( "/invalid_blocks", It.IsAny<StringContent>()))
.Returns(Task.FromResult(postResponse));
requestSender
.Setup(x => x.GetAsync(It.IsRegex(@"\/invalid_blocks\?offset=[0-9]*&limit=[0-9]*")))
.Returns(Task.FromResult(getAllResponse)); requestSender
Expand Down
87 changes: 0 additions & 87 deletions src/Thenewboston.Tests/Bank/Api/UpgradeNoticeTests.cs

This file was deleted.

Loading

0 comments on commit dbc92e9

Please sign in to comment.