public function testpairing()
 {
     $sin = $this->getMock('Bitpay\\SinKey');
     $sin->expects($this->any())->method('__toString')->will($this->returnValue('TfLG7rjKVMa9AFBaBKrS6ti8XM62yJA4D4c'));
     $client = $this->getMock('Bitpay\\Client\\Client');
     $token = $this->getMock('Bitpay\\TokenInterface');
     $client->expects($this->any())->method('createToken')->will($this->returnValue($token));
     $pairing_code = 'pairing';
     $expected_token = pairing($pairing_code, $client, $sin);
     $this->assertTrue($token == $expected_token);
 }
function pair_and_get_token($pairing_code, $network)
{
    try {
        list($private, $public, $sin) = generate_keys();
        $client = create_client($network, $public, $private);
        $token = pairing($pairing_code, $client, $sin);
        save_keys($token, $network, $private, $public, $sin);
    } catch (\Exception $e) {
        debuglog('[Error] In Bitpay plugin, pair_and_get_token() function on line ' . $e->getLine() . ', with the error "' . $e->getMessage() . '" .');
        throw $e;
    }
}