public function testInventoryVector()
 {
     $buffer = Buffer::hex('4141414141414141414141414141414141414141414141414141414141414141');
     $inv = new Inventory(Inventory::ERROR, $buffer);
     $this->assertEquals(0, $inv->getType());
     $inv = new Inventory(Inventory::MSG_TX, $buffer);
     $this->assertEquals(1, $inv->getType());
     $this->assertTrue($inv->isTx());
     $this->assertFalse($inv->isBlock());
     $this->assertFalse($inv->isFilteredBlock());
     $this->assertFalse($inv->isError());
     $inv = new Inventory(Inventory::MSG_BLOCK, $buffer);
     $this->assertEquals(2, $inv->getType());
     $this->assertTrue($inv->isBlock());
     $this->assertFalse($inv->isTx());
     $this->assertFalse($inv->isError());
     $this->assertFalse($inv->isFilteredBlock());
     $inv = new Inventory(Inventory::MSG_FILTERED_BLOCK, $buffer);
     $this->assertEquals(3, $inv->getType());
     $this->assertTrue($inv->isFilteredBlock());
     $this->assertFalse($inv->isBlock());
     $this->assertFalse($inv->isTx());
     $this->assertFalse($inv->isError());
     $inv = new Inventory(Inventory::ERROR, $buffer);
     $this->assertTrue($inv->isError());
     $this->assertEquals($buffer, $inv->getHash());
 }
 /**
  * @param Inventory $inv
  * @return \BitWasp\Buffertools\Buffer
  */
 public function serialize(Inventory $inv)
 {
     return $this->getTemplate()->write([$inv->getType(), $inv->getHash()]);
 }
 /**
  * @param Inventory $inventory
  */
 public function save(Inventory $inventory)
 {
     $this->storage[$inventory->getHash()->getBinary()] = $inventory->getType();
 }