Skip to content

Commit

Permalink
Sharing a chain between swarms can lead deadlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Aug 8, 2019
1 parent e1a8eb8 commit b7fa968
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Libplanet.Tests/Net/SwarmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,20 @@ CancellationToken cancellationToken
}

[Fact(Timeout = Timeout)]
public async Task CanExchangePeer()
public async Task ExchangePeer()
{
BlockChain<DumbAction> chain = _blockchains[0];

var a = new Swarm<DumbAction>(
chain,
_blockchains[0],
new PrivateKey(),
1,
host: IPAddress.Loopback.ToString());
var b = new Swarm<DumbAction>(
chain,
_blockchains[1],
new PrivateKey(),
1,
host: IPAddress.Loopback.ToString());
var c = new Swarm<DumbAction>(
chain,
_blockchains[2],
new PrivateKey(),
1,
host: IPAddress.Loopback.ToString());
Expand Down Expand Up @@ -317,26 +315,24 @@ public async Task CanExchangePeer()
[Fact(Timeout = Timeout)]
public async Task DetectAppProtocolVersion()
{
BlockChain<DumbAction> chain = _blockchains[0];

var a = new Swarm<DumbAction>(
chain,
_blockchains[0],
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 2);
var b = new Swarm<DumbAction>(
chain,
_blockchains[1],
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 3);

var c = new Swarm<DumbAction>(
chain,
_blockchains[2],
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 2);
var d = new Swarm<DumbAction>(
chain,
new BlockChain<DumbAction>(_blockchains[0].Policy, new FileStoreFixture().Store),
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 3);
Expand Down Expand Up @@ -378,16 +374,14 @@ void GameHandler(object sender, DifferentProtocolVersionEventArgs e)
isCalled = true;
}

BlockChain<DumbAction> chain = _blockchains[0];

var a = new Swarm<DumbAction>(
chain,
_blockchains[0],
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 2,
differentVersionPeerEncountered: GameHandler);
var b = new Swarm<DumbAction>(
chain,
_blockchains[1],
new PrivateKey(),
host: IPAddress.Loopback.ToString(),
appProtocolVersion: 3);
Expand Down Expand Up @@ -555,7 +549,6 @@ public async Task GetTx()
Swarm<DumbAction> swarmA = _swarms[0];
Swarm<DumbAction> swarmB = _swarms[1];

BlockChain<DumbAction> chainA = _blockchains[0];
BlockChain<DumbAction> chainB = _blockchains[1];

Transaction<DumbAction> tx = Transaction<DumbAction>.Create(
Expand Down

0 comments on commit b7fa968

Please sign in to comment.