Skip to content

Commit ce0fa5b

Browse files
committed
Fix failing tests
1 parent ea12be0 commit ce0fa5b

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/Blockcore/Controllers/NodeController.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ public IActionResult GetBlockHeader([FromQuery] string hash, bool isJsonFormat =
260260
/// <remarks>Requires txindex=1, otherwise only txes that spend or create UTXOs for a wallet can be returned.</remarks>
261261
[Route("getrawtransaction")]
262262
[HttpGet]
263-
public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid, bool verbose = false, string blockHash = null)
263+
public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string trxid, bool verbose = false, string blockHash = null)
264264
{
265265
try
266266
{
267-
Guard.NotEmpty(txid, nameof(txid));
267+
Guard.NotEmpty(trxid, nameof(trxid));
268268

269-
if (!uint256.TryParse(txid, out uint256 trxid))
269+
if (!uint256.TryParse(trxid, out uint256 trxhash))
270270
{
271271
throw new ArgumentException(nameof(trxid));
272272
}
@@ -278,7 +278,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
278278
}
279279

280280
// Special exception for the genesis block coinbase transaction.
281-
if (trxid == this.network.GetGenesis().GetMerkleRoot().Hash)
281+
if (trxhash == this.network.GetGenesis().GetMerkleRoot().Hash)
282282
{
283283
throw new Exception("The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved.");
284284
}
@@ -289,12 +289,12 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
289289
if (hash == null)
290290
{
291291
// Look for the transaction in the mempool, and if not found, look in the indexed transactions.
292-
trx = (this.pooledTransaction == null ? null : await this.pooledTransaction.GetTransaction(trxid).ConfigureAwait(false)) ??
293-
this.blockStore.GetTransactionById(trxid);
292+
trx = (this.pooledTransaction == null ? null : await this.pooledTransaction.GetTransaction(trxhash).ConfigureAwait(false)) ??
293+
this.blockStore.GetTransactionById(trxhash);
294294

295295
if (trx == null)
296296
{
297-
throw new Exception("No such mempool transaction. Use -txindex to enable blockchain transaction queries.");
297+
return this.Json(null);
298298
}
299299
}
300300
else
@@ -307,7 +307,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
307307
throw new Exception("Block hash not found.");
308308
}
309309

310-
trx = chainedHeaderBlock.Block.Transactions.SingleOrDefault(t => t.GetHash() == trxid);
310+
trx = chainedHeaderBlock.Block.Transactions.SingleOrDefault(t => t.GetHash() == trxhash);
311311

312312
if (trx == null)
313313
{
@@ -317,7 +317,7 @@ public async Task<IActionResult> GetRawTransactionAsync([FromQuery] string txid,
317317

318318
if (verbose)
319319
{
320-
ChainedHeader block = chainedHeaderBlock != null ? chainedHeaderBlock.ChainedHeader : this.GetTransactionBlock(trxid);
320+
ChainedHeader block = chainedHeaderBlock != null ? chainedHeaderBlock.ChainedHeader : this.GetTransactionBlock(trxhash);
321321
return this.Json(new TransactionVerboseModel(trx, this.network, block, this.chainState?.ConsensusTip));
322322
}
323323
else

src/Features/Blockcore.Features.Miner/Api/Controllers/StakingController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public IActionResult GetStakingInfo()
8686
/// <returns>An <see cref="OkResult"/> object that produces a status code 200 HTTP response.</returns>
8787
[Route("startstaking")]
8888
[HttpPost]
89-
public IActionResult StartStaking([FromBody]StartStakingRequest request)
89+
public IActionResult StartStaking([FromBody] StartStakingRequest request)
9090
{
9191
Guard.NotNull(request, nameof(request));
9292

@@ -190,7 +190,7 @@ public IActionResult StakingExpiry([FromBody] StakingExpiryRequest request)
190190
}
191191

192192
[Route("getStakingNotExpired")]
193-
[HttpPost]
193+
[HttpGet]
194194
public IActionResult GetStakingNotExpired(StakingNotExpiredRequest request)
195195
{
196196
try

src/Features/Blockcore.Features.Wallet/Api/Controllers/WalletController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ public IActionResult SendTransaction([FromBody] SendTransactionRequest request)
804804
/// </summary>
805805
/// <returns>A JSON object containing information about the re sent transactions.</returns>
806806
[Route("resend-unconfirmed-transactions")]
807-
[HttpPost]
807+
[HttpGet]
808808
public IActionResult ResendUnconfirmedTransactions()
809809
{
810810
// checks the request is valid

src/Tests/Blockcore.Tests/Controllers/NodeControllerTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public NodeControllerTest()
7575
this.CreateNewController();
7676
}
7777

78-
private void CreateNewController() {
78+
private void CreateNewController()
79+
{
7980
this.controller = new NodeController(
8081
this.chainIndexer,
8182
this.chainState.Object,
@@ -254,11 +255,10 @@ public async Task GetTaskAsync_Verbose_ReturnsTransactionVerboseModelAsync()
254255
var txId = new uint256(12142124);
255256
this.pooledTransaction.Setup(p => p.GetTransaction(txId))
256257
.ReturnsAsync(transaction);
257-
var blockStore = new Mock<IBlockStore>();
258-
blockStore.Setup(b => b.GetBlockIdByTransactionId(txId))
258+
this.blockStore.Setup(b => b.GetBlockIdByTransactionId(txId))
259259
.Returns(block.HashBlock);
260260
this.fullNode.Setup(f => f.NodeFeature<IBlockStore>(false))
261-
.Returns(blockStore.Object);
261+
.Returns(this.blockStore.Object);
262262
string txid = txId.ToString();
263263
bool verbose = true;
264264

0 commit comments

Comments
 (0)